Home » Questions » Computers [ Ask a new question ]

Linux equivalent to robocopy?

Linux equivalent to robocopy?

It’s kind of funny, there are a lot of ways in which Linux command line tools are vastly superior to Windows ones, but one thing I have not found an equivalent to is robocopy. Robocopy is way more versatile than cp, and I can’t figure out how to do what I want with Linux tools.

Asked by: Guest | Views: 14
Total answers/comments: 2
Guest [Entry]

"It sounds like rsync is definitely what you are after. You do not need to set up an 'rsync server' to copy files from one machine to another. Rsync supports copying files over SFTP (SSH File Transfer) which most linux boxes have enabled already (if not manually disabled).
See Lifehacker's Mirror files across systems with rsync for more details:

Whether you want to backup your data, distribute files securely or mirror your working documents over the internet from the office to home, between computers on your local network, or from your computer to your web server, rsync can get the job done. Today we'll use rsync to mirror folders between a Mac and PC over a secure connection at the command line.
Rsync is free (as in speech) and cross platform, meaning it syncs files between operating systems (Windows/Cygwin, Mac OS, Linux); it works over ssh so it's encrypted and secure; unlike FTP it's incremental, so only the parts of changed files are transferred, not whole files, which makes it go like Speedy Gonzalez; and the fact that it's command line makes it scriptable and easily automated."
Guest [Entry]

"If you can live without excluding the .svn directories and .pyc files, and if none of your file and directory names contain spaces, then you can just use cp at the GNU/Linux command prompt:

cp -uaT source destination

where source and destination are directories.

The -u option ensures that only newer versions from source will replace existing files in destination. See superuser.com/a/341296.
The -a option, AKA ""archive"", recursively copies directories within source while preserving time stamps and permissions, etc.
The -T option ensures that we copy the contents of source into directory, not directory source itself.

It's important that the GNU version of cp is used, as some of these options may be different or not available in other UNIX versions, e.g., macOS.

If you have spaces in your file or directory names, then you can use rsync as others have mentioned, or pipe find with -print0 to xargs with -0, which you can look into, but is beyond the scope of this answer. Both of these possibilities allow excludes."