Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

A specific use case is that I have two directories with mostly similar files, but one has newer source files and one has content files that the other directory doesn't have, and possibly newer source files (for a website). I want to copy the files from the latter directory into the former, adding new content files and such, but not overwriting newer files in the destination directory. I tried to figure out how to do this in Linux for maybe half an hour, decided that I'd probably have to learn bash scripting or something to do what I wanted, and then I realized that I could just use robocopy. I also had some other requirements. I was basically converting a Python (Django) website from an SVN repository to a git repository, and I wanted to make sure I didn't have uncommitted changes in SVN. However, I wanted to conditionally exclude the .svn directories and the .pyc compiled Python files. The following robocopy command does exactly what I want:

robocopy source destination /XO /E /XD .svn /XF *.pyc

Is there any equivalent to robocopy in Linux? I looked into rsync briefly, but it seemed like I'd have to set up an rsync server before attempting to sync the folders.

share|improve this question
You do not need to set up a rsync server, rsync over ssh automatically runs rsync on the remote machine in server mode (in a way which is used only for that connection, running under your own account, and closing automatically when it is done). –  CesarB Aug 25 '09 at 15:45

2 Answers 2

up vote 28 down vote accepted

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.

share|improve this answer
Read the rsync man page -- to use ssh (w/o an explicit rsync server) you'll use "-e ssh" –  Doug Harris Aug 25 '09 at 14:32
rsync is awesome! And you don't need to use -e since any path like user@host.com:/blah/ will automatically use it. –  The How-To Geek Aug 25 '09 at 15:49
Mmm, that's cool. So it can use basically scp-like syntax for transferring over ssh? I was actually trying to transfer files on one machine, but that is good to know. –  Ibrahim Aug 25 '09 at 18:00

rsync will copy files from one directory to another directory on the same machine like robocopy. Here is the rsync command that is equivalent to your robocopy command:

rsync -auv --exclude '.svn' --exclude '*.pyc' source destination

This will recursively copy the source to the destination and exclude older files as well as '.svn' and '*.pyc' directories/files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.