Setting up an RSYNC server on Windows Vista

I had a complete drive failure on my LaCie EDMini drive yesterday (it would start up and then turn itself off after 30 seconds). I had gotten a good 3 years of constant use out of it, though, so I shouldn’t complain. Good thing I had the automatic nightly backups to my FreeNAS server, so I didn’t lose anything permanently.

As a result I had to work though the recover process for the first time, whereby I wanted to transfer the backed-up files to a new Windows Vista Ultimate PC (using rsync of course) since this PC would become the new origin for the files going forward. This meant I had to set up the PC as an rsync server.

There are 3 primary methods for doing this (described well here). In my case, DeltaSync would have worked great except for the fact that it couldn’t handle Unicode file and folder names (even with the patched version of cygwin1.dll). So this let me to Cwrsync. Follow these steps:

  1. Download Cwrsync – all you need is the “Server Installer”.
  2. When you install it make sure you run as the normal PC user (and not the default account that it suggests). This is important; otherwise you are likely to run into insurmountable file-permissions problems later.
  3. Set up the rsyncd.conf file as per the example. E.g., I used
    [rsyncroot]
    path = /cygdrive/c/Users/USERNAME/Documents/
    comment = Rsync Root
    read only = false
    transfer logging = yes
  4. It’s not necessary to run the separate “prepare directory for upload” program, since we’re running the service as the normal user.
  5. Open up Windows Firewall and create an exception for Port 873 (the default rsync port, if you’re not going over ssh which we’re not). If you have a 3rd-party firewall you’ll need to do the same there too.
  6. On FreeNAS, I ran a bash script like the following to set up the initial push from FreeNAS to the PC. I have to set RSYNC_PROXY since I don’t want to run this over ssh. In my case, I have a partial backup there already, so I am checking on “size only” as well since the timestamps happen to be far too different between the two boxes.
    #!/bin/sh
     
    # don't use rsync over ssh
    set RSYNC_PROXY=localhost:873
    export RSYNC_PROXY
     
    /usr/local/bin/rsync -hazvrn --delete-after --progress --stats --force  \
    "/mnt/data/music" "192.168.2.4::rsyncroot"
  7. If the rsync errors out (in my case it was initially caused by some Unicode filenames left over from testing DeltaSync earlier; I don’t think it would happen on a clean setup), you may find that the file and permissions get hopelessly messed up. So open an admin command prompt and do the following:
    1. Take ownership of the folder: takeown /f c:\path\to\dir /r /d y
    2. Assign full control to Everyone: icacls c:\path\to\dir /grant Everyone:F /T

Hope this helps.

Update 1/25/10: The same directions work on Windows 7 too. However the process for opening a port in the firewall is different – you’ll have to go to Network and Sharing Center -> Windows Firewall -> Advanced Settings -> and add a new Inbound Rule for port 873 (TCP).

Leave a comment

Your email address will not be published. Required fields are marked *