Rsync: How to mirror a folder (Windows and Linux)

01 Mar 2012

Rsync is an application for UNIX/Linux and Windows systems which synchronizes files and directories from one location to another. It has some nifty features that makes it very comprehensive and above all, very very fast. It was originally created as a replacement for SCP and RCP. Many backup programs make use of the Rsync protocol.


  • Support for copying links, devices, owners, groups and permissions
  • Exclude and exclude-from options similar to GNU tar
  • A CVS exclude mode for ignoring the same files that CVS would ignore
  • Does not require root privileges
  • Pipelining of file transfers to minimize latency costs
  • Support for anonymous or authenticated rsync servers (ideal for mirroring)
Rsync only transfers files that have been modified and compresses them first before sending them over an optional secure line using SSH. Which make it an ideal backup tool.


  • Backing up filesystems
  • Downloading files
  • Uploading files
  • Mirroring files


On Linux one can just open a shell and type rsync. Should you not have installed the package, please proceed by installing it. On Debian/Ubuntu you would type:

apt-get install rsync ssh

Remember both source and destination should have Rsync installed together with ssh. Now if we want to sync one folder with another and suggesting this folder is called "myfolder" and is on our local machine in our homefolder, we need to issue the following command to send and update it to a remote server:

rsync -vauz –-delete /home/user/myfolder [email protected]:/home/myuser/destinationfolder

The v option means to show progress (verbose), the a to archive, the u to update the files that have changed and the z to compress before sending it over the network. --delete makes that files that are no longer in myfolder are deleted. Note that the destination folder needs to exist.


To backup your files from Windows to Linux one has two options:

Rsync with Cygwin

This option involves installing Cygwin on your computer after which you can use the rsync command.


This is a minimal Cygwin environment and can be installed from here. It is free for one host, but they only release 25 free packs a day. Which is quite irritating. However there is also the possibility to use older but free Cwrsync versions.


The commands are basically the same as on Windows, if you are using Cygwin, you just need to start a Cygwin shell and use the rsync.exe command. If you haven't got it installed, run the setup.exe and select the rsync and ssh package in the package selection menu. To backup a folder called backup on our C: drive to our homefolder on a remote Linux machine:

rsync.exe -vauz –-delete /cygdrive/c/backup [email protected]:

If you are using Cwrsync, you need to open a cmd. You can do this by pushing windows button+r and typing "cmd", then press enter. Go to the path where you installed Cwrsync by using:

cd "C:\Program Files (x86)\cwRsync\bin"

Now you can use


like you would do with Cygwin. Now suppose we have a folder called backup on our C: drive, and we want to back it up to a remote location, lets say our homefolder:

rsync.exe -vauz –-delete /cygdrive/c/backup [email protected]:


Rsync has many options, a reference are the man pages on Linux and Cygwin, you can access these by typing:

man rsync

If you are using Cwrsync, please have a look here.


Rsync is quite versatile and has many applications. I use it to sync my media from my Windows PC to my XBMC media system and also to backup my servers. In future articles I will elaborate more on rsync.