Introduction
We all know that backups are awesome … until we try to find the time to set them up or the space to store them. We all know that without backups we “may” see that day when we boot up our computer and our data isn’t there for whatever reason. How can we simplify backups and more importantly initiate them client side?
rdiff-backup
The backup utility that I use to accomplish backing up roaming clients is rdiff-backup. This simple python wrapper for rsync simplifies keeping incremental backups and backup sets for a historical set of backups. By default rdiff-backup is pretty versatile and its documentation is fairly extensive.
What they don’t mention is how to automate these backups with an ssh key to a remote system and a cron job as a scheduler.
The cron job
The cron job is very very simple and highly adaptable:
/usr/bin/rdiff-backup –remote-schema ‘ssh -i /home/alunduil/.ssh/backup_dsa %s rdiff-backup –server’ –exclude-other-filesystems –print-statistics /home/alunduil daneel.alunduil.com::elijah-backup && /usr/bin/rdiff-backup –remote-schema ‘ssh -i /home/alunduil/.ssh/backup_dsa %s rdiff-backup –server’ –remove-older-than 7D –force daneel.alunduil.com::elijah-backup
Now let’s break this down so you can make it yours:
- /usr/bin/rdiff-backup – Our script of course
- –remote-schema – The trick that makes it work. This actually allows you to specify the way ssh is called by rdiff-backup allowing a lot of control over how it authenticates and what happens on the server
- –exclude-other-filesystems – Specifies to stay on the mountpoint it started on
- –print-statistics – Prints some nice information about the backup when it finishes
- /home/alunduil daneel.alunduil.com::elijah-backup – The source and destination of the backup
- && – Just making sure we don’t delete old backups without having a good one (trust me you want it this way)
- –remove-older-than 7D –force – Force the removal of any backups that are older than one week
Conclusion
Creating a backup of a roaming client should be easy and with rdiff-backup with cron it certainly is. You have complete control over when and where your backups reside and it can be set to run on boot or any other condition. This is ideal for hosts that don’t always have an internet connection or who have uptimes of less than 50%.