User Tools

Site Tools


efficient_backups_with_rsnapshot

This is an old revision of the document!


Efficient backups with rsnapshot

(I need to write a full article here, but I don't have time now. Basically: stick rsnapshot on a Linux box, set up SSH keys to get into hosts you want to back up, deploy a secure rsync wrapper when you configure the host SSH key for backup access, then set up a cron job to run the thing.)

Backing up Windows hosts

Normally, all you'd need to do to make the server back up Windows hosts is to install Cygwin with SSH and rsync and set up SSH keys as normal. Unfortunately, there's a bug in cygwin that causes rsync over SSH to hang on certain directory trees, and this bug hasn't been solved in years (way to go, open source!).

So we'll set up rsyncd, the dedicated rsync service.

First, install Cygwin with rsync and anything else you might like.

Second, set up rsyncd as a service:

$ cygrunsrv --install "rsyncd" --path /usr/bin/rsync --args "--daemon --no-detach" --desc "Starts a rsync daemon for accepting incoming rsync connections" --disp "Rsync Daemon" --type auto

Third, set up /etc/rsyncd.conf file:

uid = nobody
gid = nobody
use chroot = no
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
read only = true
hosts allow = <BACKUP_SERVER_IP>
 
[root]
	path = /
	auth users = <USERNAME>
	secrets file = /etc/rsyncd.secrets

Populate the user list /etc/rsyncd.secrets:

<USERNAME>:<PASSWORD>

Then, on the backup server, create a file /root/cron/<WINDOWS_HOST>-rsync-password:

<PASSWORD>

Now you can add backup lines to your rsnapshot.conf as follows:

backup	rsync://<USERNAME>@<WINDOWS_HOST>/root/<PATH>	<WINDOWS_HOST>/	rsync_long_args=--password-file=/root/cron/<WINDOWS_HOST>-rsync-password --no-numeric-ids --delete --relative --delete-excluded

The <PATH> looks is a cygwin path, so it looks like "/cygdrive/<DRIVE_LETTER>/<PATH>" (e.g. "/cygdrive/c/My Documents/"). If you've changed the drive path to "/" as mentioned in Cygwin SSH Server for Windows, then omit the "/cygdrive" part.

If you want to back up something like your Firefox profile that will have certain files locked, exclude those files. For example:

backup	rsync://<USERNAME>@<WINDOWS_HOST>/root/c/Users/<USERNAME>/Application\ Data/Mozilla	<WINDOWS_HOST>/	rsync_long_args=--password-file=/root/cron/<WINDOWS_HOST>-rsync-password --no-numeric-ids --delete --relative --delete-excluded --exclude cookies.sqlite-journal --exclude parent.lock --exclude places.sqlite-journal
efficient_backups_with_rsnapshot.1259767432.txt.gz · Last modified: 2009/12/02 07:23 by tkbletsc