Bytemark backup script

As some people are aware, I use Bytemark for all of my hosting, and I also resell some of their services. I’ve recently switched to performing my backups via rsync and thought I would share the simple script I use in case any other Bytemark customer is looking to do the same thing.

#!/bin/bash

BACKUPDIRS="/etc /home"
VMNAME=""

for dir in $BACKUPDIRS ; do
rsync --delete -qazr "$dir" $VMNAME.backup.bytemark.co.uk::$VMNAME/"$dir"
done

The only change required is that you need to set the VMNAME variable to the name of your virtual machine, and change BACKUPDIRS to list all the directories which you want to backup.

Some important caveats:

  1. You must have Bash installed in order for this script to work, though it doesn’t have to be your default shell.
  2. This script will not backup non-file data, such as MySQL databases. I will post a separate script once I get round to performing this task.
  3. The complete contents of the directories specified in BACKUPDIRS will be backed up, there is no way to say ‘backup /home but not /home/paul‘.
  4. The first time you run this script it will take a while for rsync to copy all the data, but subsequent runs should be much faster.
  5. I think this only works for virtual machines and not dedicated hosts.

As rsync only copies the files required, you can probably run this script more frequently than a full backup script.