rdiff-backup strategy

To backup windows using rdiff-backup to another computer, four sub-systems need to be configured:

  1. Install cygwin (including rdiff-backup) on the windows machine
  2. Configure and test rdiff-backup across ssh using manual passwords
  3. Configure public key authentication for passwords
  4. Configure scheduled tasks to run the process automatically

1. Install cygwin

Just follow the instructions on cygwin.org and remember to include rdiff-backup (and rsync if you need it)

2. Configure and test rdiff-backup

Here is my script:

rdiff-backup /cygdrive/c/Common jordan-backup::/backup/stillwater/Common
rdiff-backup /cygdrive/c/Users\ Shared\ Folders jordan-backup::/backup/stillwater/UsersSharedFolders
rdiff-backup --exclude-globbing-filelist sw-exclude.txt /cygdrive/c jordan-backup::/backup/stillwater/c

This assumes that there is an “exclude” file in the same directory in which the program is run from. See at the end for mine. I also wanted to do a database dump into a directory that would be backed up. Here is my dump command:

'/cygdrive/c/Program Files/MySQL/MySQL Server 5.0/bin/mysqldump.exe' -u xxxx -p --compress --add-drop-table --extended-insert -A > /cygdrive/c/Common/MySQLBackup/stillwater.sql

3. Configure public key authentication

An excellent tutorial for this is available on: arctic.org/…up/unattended.html but note that they are initiating backup from the host.

(A cached version is available here.)

  1. On server (host):
#useradd --home /var/backups --create-home --shell /bin/false backup # already created in Ubuntu
mkdir /var/backups/.ssh
chown backup /var/backups/.ssh
su -m backup # Create a passphrase-free ssh key
ssh-keygen -t rsa
#Enter file in which to save the key (/backup/.ssh/id_rsa): /var/backups/.ssh/id_rsa_myserver_backup
#Enter passphrase (empty for no passphrase):
chmod -R go-rwx /var/backups/.ssh
scp /var/backups/.ssh/id_rsa_myserver_backup.pub root@client:.ssh/
  1. On client to be backed up
su #make sure you are root if backups are run as root
chmod 700 ~/.ssh/id_rsa_${MYSERVER}_backup
echo "host ${MYSERVER}-backup" >> ~/.ssh/config
echo "        user backup" >> ~/.ssh/config
echo "        hostname $MYSERVER" >> ~/.ssh/config
echo "        identityfile /root/.ssh/id_rsa_${MYSERVER}_backup" >> ~/.ssh/config
echo "        protocol 2" >> ~/.ssh/config
#echo "        compression yes" >> ~/.ssh/config # if necessary
#echo "        port 7654" >> ~/.ssh/config # if necessary

ssh ${MYSERVER}-backup # try connecting with no password

4. Configure scheduled tasks

Create a file called daily-backup.bat (the —login creates path and environment variables):

C:\cygwin\bin\bash --login \common\scripts\rdiff.sh

Create a file called rdiff.sh (which must have unix line endings):

rdiff-backup commands... (as tested above)


/cygdrive/c/Program Files/Exchsrvr
/cygdrive/c/Program Files/Microsoft?SQL?Server


  • See what has changed in the last 35 days
rdiff-backup --list-changed-since 35D root@jordan::/backup/sv/home/common/Active\ Files/Willson/
  • Restore a file from 7 days ago
rdiff-backup -r 7D root@jordan::/backup/sv/home/common/Active/file2012.txt /home/common/Active/file2012.txt

Clean up

  • Operation done on repository, but cannot be done on individual folders
rdiff-backup --force --remove-older-than 4W /backup/cfahome