Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Robocopy commands in CP replacement
#1
Hello, I work a lot with windows in my work and I love robocopy, but more and more I try to bring linux into my work. On the other hand, I try the CP copy commands, but I can not find some arguments equivalent to robocopy.

in robocopy, I use:
1- / mir to copy the entire file and folder tree into the selected source
2- / R: 2, to try to copy twice in case of failure
3- / W: 2, to wait 2 seconds between each failed copy attempt.

so here is what it looks like:

robocopy E:\user\admin\documents H:\back_up\documents /mir /R: 2 /W: 2

But I wonder what arguments I should put for the CP commands.

if you have other alternative, i'm open too.


Thank you in advance for your help

robocopy arguments: https://www.computerhope.com/robocopy.htm

Cp arguments: https://www.computerhope.com/unix/ucp.htm
Reply
#2
Hi!

I am not sure everything you do is possible with it, but rsync is usually the tool that is suggested for copying to network drives:
https://linux.die.net/man/1/rsync
I am discovering Arch Linux as a total Linux newbie, and try to share my experience. I've managed to produce a working bootable USB and got my main PC up and running!
Reply
#3
(10-01-2019, 04:05 PM)TarsolyGer Wrote: Hi!

I am not sure everything you do is possible with it, but rsync is usually the tool that is suggested for copying to network drives:
https://linux.die.net/man/1/rsync

It is for usb or local drives, not networks drives
Reply
#4
(10-01-2019, 02:50 PM)JD1er Wrote: 1- / mir to copy the entire file and folder tree into the selected source

'-r' (for "recursive") to copy directories. Without that flag, directories will be ignored.

(10-01-2019, 02:50 PM)JD1er Wrote: 2- / R: 2, to try to copy twice in case of failure
3- / W: 2, to wait 2 seconds between each failed copy attempt.

If 'cp' fails, trying the exact same operation again is extremely unlikely to work.
Basically, these options are not needed.


(10-01-2019, 02:50 PM)JD1er Wrote: robocopy E:\user\admin\documents H:\back_up\documents /mir /R: 2 /W: 2


To create a copy of directory-1 inside directory-2, if directory-2 already exists:
Code:
cp -r directory-1/ directory-2/
The same command will create directory-2 as a copy of directory-1, if directory-2 does not exist already.

To copy the contents of directory-1 inside directory-2 (which has to exist or the operatin will fail):
Code:
cp -r directory-1/* directory-2/
'*' is a wildcard. It is used here to select the contents of directory-1 instead of directory-1 itself.


Note that 'cp' will simply overwrite all files if there are naming conflicts. You can use '-n' to disable overwriting completely or '-i' if you want to decide for each file individually.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#5
(10-01-2019, 05:41 PM)leon.p Wrote:
(10-01-2019, 02:50 PM)JD1er Wrote: 1- / mir to copy the entire file and folder tree into the selected source

'-r' (for "recursive") to copy directories. Without that flag, directories will be ignored.

(10-01-2019, 02:50 PM)JD1er Wrote: 2- / R: 2, to try to copy twice in case of failure
3- / W: 2, to wait 2 seconds between each failed copy attempt.

If 'cp' fails, trying the exact same operation again is extremely unlikely to work.
Basically, these options are not needed.


(10-01-2019, 02:50 PM)JD1er Wrote: robocopy E:\user\admin\documents H:\back_up\documents /mir /R: 2 /W: 2


To create a copy of directory-1 inside directory-2, if directory-2 already exists:
Code:
cp -r directory-1/ directory-2/
The same command will create directory-2 as a copy of directory-1, if directory-2 does not exist already.

To copy the contents of directory-1 inside directory-2  (which has to exist or the operatin will fail):
Code:
cp -r directory-1/* directory-2/
'*' is a wildcard. It is used here to select the contents of directory-1 instead of directory-1 itself.


Note that 'cp' will simply overwrite all files if there are naming conflicts. You can use '-n' to disable overwriting completely or '-i' if you want to decide for each file individually.

Thanks a lot and the reason i put the retry was more for forcing the program to pass to the next if it was unable to copy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)