Recently, and without much fanfare, Dreamhost introduced backup users. Each account gets a single backup user, whose function is to provide a remote backup. Dreamhost’s TOS states that regular user content must be served on the web: it is not intended to be a backup service. However, clearly the need for remote backups exists, and so they now allow 50GB (plus more at the rate of $0.10 per GB per month) of backup space for each account, accessed through the backup user.
So I’m backing up my email remotely. Just the job for a shell script. First things first: what do I need to backup? Well I use Evolution for email, and first I need to stop things from changing while I backup, and make sure I’m starting from the right place:
Next, I need to backup three directories, and encrypt them of course. (The recipient here is changed for security purposes.)
tar -cz .gconf/apps/evolution .gnome2_private/Evolution .evolution
| gpg -e -r firstname.lastname@example.org -o mail.tar.gz.gpg
Now of course I need to upload the backup to the dreamhost backup server via SFTP (Once again the username here is changed for security purposes.):
sftp -b /dev/stdin email@example.com <<EOF
And finally remove the intermediate file:
Having previously uploaded my authorized ssh key to avoid having to type a password, of course, this process is now automated. The only fly in the ointment is that Dreamhost backup users only support FTP or SFTP; ideally they’d have support for rsync.