Now that our low-budget file server (a stock Dell Inspiron 531S desktop with an additional 500 GB SATA drive) is up & running Xubuntu 8.10, it’s time to get rsnapshot working again.
All our data files live on the server, so the backup routine need not handle any of the usual /home stuff on our desktop boxes. Rebuilding a dead box is a nuisance, but they’re all pretty much the same and it’s less of a nuisance not worrying about rare failures… haven’t had any failures in many years; they get replaced before they die.
The backup files go to an external 500 GB USB drive, which is not protection against a catastrophe in the basement. Mostly, this guards against finger fumbles; the external drive gets dumped to another hard drive in the fireproof safe more-or-less monthly.
So. To begin…
Install rsnapshot, which will also drag in ssh, the metapackage around the client & server sides of openssh. The server side is already installed so I can sign in using public-key authentication.
Set /etc/rsnapshot.conf thusly (comments snipped out):
snapshot_root /mnt/backup/snapshots no_create_root 1 cmd_cp /bin/cp cmd_rm /bin/rm cmd_rsync /usr/bin/rsync cmd_ssh /usr/bin/ssh cmd_logger /usr/bin/logger cmd_du /usr/bin/du cmd_rsnapshot_diff /usr/bin/rsnapshot-diff #interval hourly 6 interval daily 30 #interval weekly 4 interval monthly 12 #interval yearly 1 logfile /var/log/rsnapshot du_args -csh backup /mnt/userfiles/ oyster/ backup /mnt/bulkdata/ oyster/ backup /mnt/music/ oyster/ backup /mnt/diskimages/ oyster/
Basically, that creates a month of daily backups, plus monthly backups for a year. Haven’t ever gotten to a yearly backup, but you get the idea.
The no-create-root option prevents horrible things from happening if the USB drive wakes up dead and doesn’t mount; you don’t want to back up the drives to the /mnt/bulkdata mount point. The USB drive mounts using a UUID entry in /etc/fstab, as described there.
Create a pair of scripts in /root to mount the USB drive, do the backup, unmount it, and shut down the system:
#!/bin/sh logger "Mounting USB drive" mount /mnt/backup logger "Starting backup" /usr/bin/rsnapshot daily logger "Unmounting USB drive" umount /mnt/backup logger "Power off" shutdown -P now logger "Done!"
#!/bin/sh mount /mnt/backup /usr/bin/rsnapshot monthly umount /mnt/backup shutdown -P now
Note: the rsnapshot executable has moved from /usr/local/bin in Ubuntu 7.10 to /usr/bin in 8.10.
You could be more clever than that, but, eh, they’re simple & easy.
The Inspiron 531S 1.0.13 BIOS now powers off dependably with the 2.6.27-14-generic kernel in 8.10, a pleasant change from the 1.0.12 BIOS and the 2.6.22-16-generic kernel used in 7.10. That means the shutdown commands work and I can shave 25% off the server’s power bill. Not that it’s very big to begin with, but every little bit helps.
Set up /etc/crontab to run the backups (and sync the system clock with reality, for the reasons described there):
10 23 1 * * root /root/rsnapshot.monthly 30 23 * * * root /root/rsnapshot.daily # 00 01 * * * root ntpdate north-america.pool.ntp.org
And that’s it.
Memo to Self: add e2fsck to the monthly backup routine and move it an hour earlier.
4 thoughts on “Backup with Rsnapshot”
Comments are closed.