RSYNC on WinXP

Here is a little tip to use RSYNC on a computer running Windows XP. I haven't tried but I guess this tip must work on a Windows 2000 machine as well.

Why to use Rsync ? In fact the reason is simple. Since few time I have a laptop (at last !!) and I wanted to synchronize my laptop with my NFS account on the LIP6 server. Then I can benefit of an automated backup thanks to the nice admin's of the lab and work easily everywhere with all my data without any need of an Internet connection.
So how to deal with it ...

First of all, you have to download this little file : Rsync_WinXP.zip. This is a simpler version of some tools I downloaded from a webpage maintained by Robert Scholten (Big thank you to him).

Installation

Unpack the zip file in a directory : let say c:\Program Files\Rsync Add some environment variable your system. Open the System property sheet and chose the Advanced Tab. Click the "Environment Variables" button and add the following User Variables :

VariableValue
CYGWINbinmode tty
HOMEc:\Program Files\Rsync
RSYNC_RSHssh.exe
TERMansi
USERNAMEyour_user_name
PATHc:\Program Files\Rsync;the_other_values_of_PATH

From now on you have rsync in your command window.

Configuration

Create a directory that will contain the copy of your NFS account, let say : c:\SyncDir.

I guess that like me, you are not interested in synchronizing you system files (.ntprofile, .gnome, ...). It is mainly useless and will increase the quantity of data to synchronize for nothing.
In order to prevent these files to be synchronized I wrote a little exclude file that you can download as an example. It lists all the files and directory you don't want to synchronize. A deeper description can be found on the web (just try Rsync in Google).
Just an important remark, this file must be saved in a UNIX format (no CR/LF characters), otherwise it won't work.
After you adjust the exclude file to your will, just save it in c:\SyncDir\.

Using Rsync

Now you just need to write 2 little batch files to make your life easy.(like RsyncToLaptop.bat and RsyncToServer.bat for example). Create them in c:\SyncDir\ where you put the exclude file, and put a shortcut on your desktop for each of them.
The syntax for these BATCH files is the following:

rsync -e ssh -avru --exclude-from=<exclude-file> <path to src> <path to dest>
<path to src> and <path to dest> can take the following pattern : [[login@][host:]]src

Options

-a : archive mode
-r : recursive
-u : update
-v : increase verbosity

Useful options

-vvv : for a very verbose rsync : useful to solve troubles
--dry-run : to check what rsync would do
--delete : this will delete files at the destination that are not present in the source. To use carefully !!

Comments

Rsync provides a lot of options, I advise to have a look at them before writing the BATCH files you need.
Be particularly careful with the --delete option, it require a personal effort to avoid loosing files.
Personally I spent some time fighting with configuration problems, I hope this can prevent you from wasting too much time :).