Required Software

The required are available through the cygwin distribution. You can download cygwin from http://www.cygwin.com/. The authentication protocol used in rsync is a 128 bit MD4 based challenge response system. Please note that the packets sent between the client and servers on port 873 are not encrypted. For encryption support you can configure rsync to run over ssh.

Install with the following selections as a minimum:

(1.1) +Editors Install nano for use as a simple text editor (or install one of the others if you are familiar with them), as in the following example screen.

unix1 Synchronize a Unix machine with Windows

(1.2) +Net Install Rsync as in the following example screen. (It is not installed by default)

unix2 Synchronize a Unix machine with Windows

(1.3) +Admin To use Rsync as a Service under Windows, you must expand the +Admin section and select cygrunsrv NT/W2k service initiator.

unix3 Synchronize a Unix machine with Windows

You will need to tell Windows where to find the Cygwin /bin directory, otherwise apps called from outside Cygwin will fail. Do this by adding C:\Cygwin\bin; to the PATH statement.

On Windows 2003/XP, open the Control Panel and double click on the System applet. Click on the Advanced tab, then click the Environment Variables button. Double click on the PATH statement in the ‘System Variable’ screen (lower of the two), add the path on the end, and click OK. Click OK to close the Environment Variables screen, then click OK to close the System Properties dialogue box. The path will be dynamically reloaded (no need to reboot).

Note: If the end of the path looks something like this: C:\Somepath don’t forget to add ; before you add the C:\Cygwin\bin; e.g. C:\Somepath;C:\Cygwin\bin;

Configuration

Make sure Rsync is installed.

Choose the path for your area: This can be on a per-user basis ( a Users data to their /home/user area) or on a system level basis (a single machine backing up to one directory.)

Create the /etc/rsyncd.conf and /etc/rsyncd.secrets files. [Check out the Manual pages for rsyncd.conf for more info.]

Here is an example of an rsyncd.conf file:

[modulename]

path = /home/syncuser/data
uid = syncuser
gid = syncuser
read only = false
auth users = syncuser
secrets file = /etc/rsyncd.secrets

The permissions for this file should be: -rw-r–r– (644) and root root.

The corresponding rsyncd.secrets file contains the following entry (username:password):

syncuser:SyncUser1

The permissions for this file should be: -rw——- (600) and root root.

Start Rsync in daemon mode.

Windows Configuration

In order to synchronise your Windows machine effectively, I would recommend the use of a batch file, as in the following:

@cls
@echo off

rem Rsync job control file

C:\Cygwin\bin\rsync -vrtzu –password-file=c:\cygwin\secret /cygdrive/d/data/ syncuser@company.com::modulename

An explanation:

C:\Cygwin\bin\rsync – is the full path to ‘rsync.exe’.

-vrtzu – verbose (tell us what is being copied), recursive (descend into directories), transfer modification times, z (compress data), u (skip newer files).

–password-file=c:\cygwin\secret – Path to ‘secret’ file.

/cygdrive/d/data/ – in this example means D:\data.

syncuser@company.com::modulename – is the user ID, hostname (can be IP address if over Local Network), and the module connection name (in this example ‘modulename’).

You will now have to create the ‘secret’ file that Rsync uses for its authenticating password.

Login to Cygwin.

Create a file called ‘secret’ in the root of the Cygwin application (i.e. cd /). Enter the client’s password with no spaces and no carriage returns; (in this example: ‘SyncUser1′ to match syncuser:SyncUser1 in the server’s /etc/rsyncd.secrets file). Assign the file 600 permissions (chmod 600 secret). This is the file ‘–password-file=c:\cygwin\secret’ as referred to above. If you create the secret file as a user (i.e. not logged in as ‘Administrator’), you will need to change the ownership of the file: chown Administrator:Domain Users should work for Servers; chown Administrator:SYSTEM should work for Workstations.

Now schedule this batch file (using the Windows Schedule Tasks application) to run whenever you which to synchronise. For example, schedule to start every day at 6am and the repeat every 10 minutes until 11pm.