Skip to content

The importance of rsync

What is rsync

rsync is a tool commonly found in *nix systems for the synchronization of files across different machines. Put simply, it is a file transfer tool that has various uses. It is commonly used in backup solutions. It is fairly easy to get it working under windows with good results.

Why rsync

So why rsync? Why not just transfer files via FTP/Samba/NFS every x amount of days? The reason for using rsync is because I’ve been relying on a boring backup routine for years. When creating a backup I usually do it manually — This means opening up an SFTP connection, finding the files I want to backup, and with some of them I may want to compress them. This can take a considerable amount of time and the possibility of you missing a file that you perhaps meant to backup is too high. I decided it was time for a proper backup solution. I had been hearing about rsync and been meaning to take a look at it for quite a while, so off I went.

Using rsync allows you to create a nice scripted solution which just works — you can just run your script and it’ll perform your entire routine for you. You can run it transparently if you really want. The amount of software required is also minimal (no crappy shareware stuff, etc..)

How to use rsync

This isn’t really about how to use rsync but rather how _I_ use rsync. I have two drives connected to my NAS and that stores files which I wish to be backed up. This NAS has an SSH server running on it (openssh-server) in order to accept SSH/SFTP/RSYNC connections.

In order to allow my windows machines to use rsync I must use cygwin []. When installing cygwin make sure you enable rsync.

In order to synchronize files you must enter cygwin and issue a command like the following:

rsync -e ssh -av −−delete “/cygdrive/e/Music/”

In this instance, I am synchronizing my music collection located at E:Music (in cygwin this becomes /cygdrive/e/Music) into /media/disk1/Music/ on the other machine (located at

The −−delete option is used to remove files on the destination server that no longer exist in the new file list. See the man pages (man rsync) for more details. Once you have gotten rsync working and can sync some files, you may realise that you need to enter a password each time.


In order to create backups without having to enter a password every time, you will need to create a private/public keypair. To do this, run ‘ssh-keygen -P “”‘ within cygwin.

This will create a keypair that does not require a password. By default this is saved into ~/.ssh/ (which becomes Copy this file to the remote machine and append it to ~/.ssh/authorized_keys on the remote machine (cat >> ~/.ssh/authorized_keys).

In my case, I created a seperate user on the remote machine called ‘rsync’ and then appended the created in cygwin to /home/rsync/.ssh/authorized_keys. I could then prefix the rsync address with a username (e.g. rsync@ and it would use the rsync account rather than my main account.

You should now be able to login without having to enter a password every time rsync creates a connection. Just make sure nobody can obtain your key file.

Automating and shortcuts

The first thing you should do is create a shell script which contain the rsync commands you wish to execute. In my example,

# Critical data and other misc data
rsync -e ssh -av −−delete −−exclude “/cygdrive/e/data/global/” “/cygdrive/e/data” rsync@
# Global data
rsync -e ssh -av −−delete “/cygdrive/e/data/global” rsync@
# Music
rsync -e ssh -av −−delete “/cygdrive/e/Music/” rsync@

Running ‘sh’ will then execute the above shell script and the appropriate files will be backed up. In order to link this shell script with an ordinary windows shortcut you will have to copy rsync.exe (located in drive:cygwinbinrsync.exe) to the WINDOWS directory (or include rsync.exe into your path variables).

You can then create a batch file like the following:

@echo off

chdir D:cygwinbin

bash ‘’
bash ‘’
bash ‘’

Then if you really wanted to you could merely create a desktop shortcut to this batch file. Awesome.

Further Information

Here are some further links to help you.–mirror-files-across-systems-with-rsync-196122.php

Published inUncategorized
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x