Friday 22 March 2013

Getting rdiff-backup to work with Window 7 and Cygwin

I think that rdiff-backup has great potential to fulfil my backup needs.  Its only draw back was that I couldn't get it to work.   More specifically, running under Cygwin on Windows 7, the first backup would work just fine, but then the second backup would fail with directory permission errors.  I posted to the rdiff-backup mailing list asking for help and a guy called Dominic Raferd suggested that the problem might be with the Cygwin permissions.  I decided that a needed to run a test to see if he was correct.

First of all I set up my test case.  I made a new "backup-test" directory and populated it with a single file "test.txt".  I then backed up the folder with:

rdiff-backup -v5 /cygdrive/c/backup-test rdiff@localserver::bu/backup-test

Which as expected worked just fine. Without changing anything I repeated the command:

rdiff-backup -v5 /cygdrive/c/backup-test rdiff@localserver::bu/backup-test

This one failed, as expected, with a python stack-trace complaining about file level permissions.

Dominic Raferd suggested that to fix the issue I needed to change the group in Cygwin of the directory I was backing up.  Here's what I applied:

First I checked in /etc/group to find that the id of the Users group was 545. Next I edited /etc/passwd to set my "primary group" to 545. I then started a new Cygwin shell. I ssh'ed onto the backup server and deleted the backup-test directory. I also deleted and recreated the local backup test directory.

With that all in place, I reran the backup line twice. It failed. Same permissions error on the remote files.

Checking the local directory, I noticed that the backup folder had no access permissions set. I made a brand new folder and sure enough it also had no permissions set.

$ ls -ld /cygdrive/c/test
d---------+ 1 dave None 0 Mar 22 22:11 /cygdrive/c/test

With a bit of Googling, stackoverflow gave me my next lead. As they suggest, I edited /etc/fstab and added this at the end:

none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

I restarted Cygwin, cleaned the folders local and remote, and tried the double backup again.  It worked like a charm!

No comments: