Categories
Command Line Linux Passwords RSync SSH Ubuntu Windows

What is the Linux equivalent to RoboCopy?

The Linux equivalent to Window’s robocopy is the command line file mirroring utility called rsync.

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.

Rsync Switches
To see all the available options, type rsync --help at the command line. Here are a few of the options:

  • -r, –recursive – recurse into directories
  • -u, –update – skip files that are newer on the receiver
  • -n, –dry-run – show what would have been transferred
  • –existing – only update files that already exist on receiver
  • –delete – delete files that don’t exist on the sending side
  • -z, –compress – compress file data during the transfer
  • –exclude=PATTERN – exclude files matching PATTERN

If you’re just getting started with rsync, the -n (“dry run”) switch with -v (verbose) is a great way to see what files would get copied without actually performing the copy. Use that switch to test out your rsync recipe before you run it.

Of course, once you get your rsync command just right, you can place it in a batch file or shell script and automate it using Windows Task Scheduler (or cron on the Mac or a Linux machine). The only problem here is that you’ll get a password prompt every time to log into the machine you’re ssh’ing into; use this handy tip on how to set up passwordless ssh logins to automate rsync without the prompt.

Rsync will run on OS X, Ubuntu, Debian, Red Hat, SUSE, etc. You can even run it on Windows machines with Cygwin which is a Linux-like environment for Windows.

More about Robocopy