Backed that thing up

I’ve had a lucky streak: even with the occasional hard drive failure I haven’t had any major data loss for a long time. But tempting fate all this time has become worrisome, so a couple of days ago I signed up for an account at rsync.net, a place that charges $1.60/GB/mo for network accessible hard drive space. This solves the problems I’ve always had with using my own disks or DVDs for backup: if it isn’t automatic I won’t do it, and it had better be offsite. As a bonus, they gave me half off for being open source developer. My setup detailed after the jump.


Here’s how I set up my machines to use it:

First, I created the RSA key for rsync.net and copied to the remote server:


$ ssh-keygen -t rsa
$ scp ~/.ssh/id_rsa.pub account@machine.rsync.net:.ssh/authorized_keys

I want to have two directories on my storage space: one that is just a subversion root with various open source software, my websites, etc. And a second that has sensitive things such as tax returns or email mbox files, all encrypted. I haven’t set up the second part, but the plan is to create a disk image for dm-crypt and then sync that up to the server. One could even use sshfs to mount the remote file system, then mount the image with dm-crypt directly so you can just copy files into it without having to keep an encrypted disk image locally.

For non-sensitive stuff, I created a directory containing symlinks to directories I want to backup. The rsync program sports a command line switch to resolve any symlinks that go outside the current tree, but maintain those that are inside. This works out great because a link inside a source tree stays a link, but the link from the backup directory to the tree itself results in the tree getting copied.

I put this in my crontab along with scripts to periodically mirror my web page and my LJ:


crontab:
0 4 * 1 * cd projects && wget -r -N http://bobcopeland.com
0 5 * 1 * cd projects/ljdump && ./ljdump.py
30 13 * * * cd /backups && ./sync.sh

sync.sh:
rsync -avz --copy-unsafe-links -e ssh stuff me@machine.rsync.net:

With this setup, I just have to link the non-sensitive things I care about under the /backups/stuff directory, and that will get replicated to the offsite backup daily. My website and LJ get mirrored once a month and synced that day to the remote server.

Bring on the nukes!