Using rsync to back up a Windows box to Ubuntu Server 8.04

After getting rsync working so well for backing up hard drive to hard drive, I naturally wanted to back up from my Windows box to my Ubuntu server. Luckily, Cygwin has an rsync for Windows – so I started by installing that. (I actually already had it installed – Cygwin is nice.)

I found some good instructions here, and used them as the basis for what I did.

The steps I went through:

  1. First I created /etc/rsyncd.conf. I wanted to share a single directory called shared, so I had just one entry:
    comment=Shared directory
    read only=false
    auth users=rsyncuser
    secrets file=/etc/rsyncd.secret

    I picked group sambashare just to be consistent with my Samba configuration. rsyncuser does not exist on the machine; it is instead mapped to andrew (uid)

  2. Next I created /etc/rsyncd.secret:
  3. After that, I needed to enable rsync (both right now and after reboot). First, I edited /etc/default/rsync and changed RSYNC_ENABLE to true:

    Next I started the rsync daemon:

    sudo /etc/init.d/rsync restart
  4. The /etc/inetd.conf of a plain Ubuntu 8.04 Server install was empty, which was a surprise to me. There appears to be a utility called “update-inetd” to update the file and then restart inetd. Because I couldn’t be bothered to find out the syntax, I just edited /etc/inetd.conf and put in:
    rsync  stream  tcp     nowait  root    /usr/local/bin/rsync rsyncd --daemon

    Then I used update-inetd from the command line to restart inetd for me:

    sudo update-inetd --disable rsync
    sudo update-inetd --enable rsync
  5. At this point, I could telnet to port 873 (the rsync port) and see a connection, but rsync itself still didn’t want to run. Instead, it failed (even when I entered the correct password) with this message:
    @ERROR: auth failed on module shared
    rsync error: error starting client-server protocol (code 5) at main.c(1383)

    Andrew Tridgell has awesome utilities, but he really has a problem with displaying meaningful messages.

    It turns out that rsync really wants the secrets file (in my case /etc/rsyncd.secret) to be readable only by the rsync user. There is a global option “strict modes” that can be set to false to allow you to get around this, but I decided why not just do the right thing:

    sudo chown root.root /etc/rsyncd.secret
    sudo chmod 400 /etc/rsyncd.secret
  6. Finally, I needed a command for the rsync on my Windows box. Here was one I came up with:

    @echo off
    set RSYNC_PASSWORD=secretrsyncpassword
    rsync -vrtz --delete --delete-excluded --exclude "Temp/" --exclude "*.tmp" --exclude "parent.lock" --exclude "UsrClass.dat*" --exclude "NTUSER.DAT" --exclude "ntuser.dat.LOG" --exclude "Cache/" "/cygdrive/c/Documents and Settings/" "rsyncuser@myserver::shared/win2k-backup/Documents and Settings"

    This command preserves timestamps (t) and prints out what it’s doing (v) as it recursively (r) goes through Documents and Settings and backs up the files, using compression so it’s faster over the net (z). It excludes a bunch of things.

I should probably have used a file to specify what’s excluded (–exclude-from), but I was lazy and just kept adding to the command line. I’m excluding cache files, as well as lock/log files that are kept open by Windows 2000 (they report as errors if you try to back them up).

At some point I’ll probably add a “hosts allow” line to my /etc/rsyncd.conf, as soon as I decide which machines I want to let backup to the server.

2 Responses to Using rsync to back up a Windows box to Ubuntu Server 8.04

  1. Jim C. says:

    One issue you might run into using cygwin rsync is the path limit imposed by Cygwin’s use of CreateFileA() rather than CreateFileW(). As per MSDN (, the Ansi version of CreateFile() is limited to a maximum path length of 250 characters. Getting around this limitation is not trivial.

    Otherwise, the cygwin rsync is a nice solution for simple desktop backups

    Jim C.

    • andrewmemory says:

      Good point. I’m not sure if Cygwin 1.7 solves this or not. They now claim:

      – PATH_MAX is now 4096. Internally, path names can be as long as the
      underlying OS can handle (32K).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: