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:
- First I created /etc/rsyncd.conf. I wanted to share a single directory called shared, so I had just one entry:
[shared] path=/data/shared comment=Shared directory uid=andrew gid=sambashare 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)
- Next I created /etc/rsyncd.secret:
- 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
- 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
- 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
- Finally, I needed a command for the rsync on my Windows box. Here was one I came up with:
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.