Skip to content

Backups

Everyone has been bitten at least once over the years when a critical system crashes… and you have no backup. Since I run a production site used by thousands of people across the globe daily, being unprepared like that is simply not an option for me.

I back up all critical data every day. The sheer volume of it (multiple tens of Gigs) means I have to split up the tasks across the least busy time slot for the server. Since the server is used globally, there really is no down time, but usage data show that the most quiet period, on average, is between 08:00 - 12:00 GMT. That’s when I do the backups.

So what do I backup, and how?

The service itself consists of thousands of cvs repositories, the associated database records for the members, and the forums database. All of these can be successfully backed up using simple file techniques. This is all managed via cron, and runs like clockwork (pun intended).

The technique I use may be useful to you as well: I use a rolling day-named backup file. My backup script determines what day it is, for example Friday, and then produces a backup of the fileset under action as ‘foobar-backup-Friday.tar.gz’. The next day the script runs, a file name ‘foobar-backup-Saturday.tar.gz’ is created alongside the others. When the next Friday rolls around, the existing Friday backup gets overwritten with the new one. Nothing fancy here, just rock-soild dependable backups that are never more than 24 hours old.

These get archived off-system and off-site routinely as well, so these files aren’t the only line of defense against a disaster, they are simply the first and most important.

Here’s the very simple script for doing just a backup:


TODAY=`date +%A`
REPOSITORY=/some/location/on/disk
BACKUP_DIR=/some/other/location/

tar cvzf $BACKUP_DIR/some-file-set-backup-$TODAY.tar.gz --exclude /do/not/backup/this/dir $REPOSITORY

Notice that I use the ‘v’ option to tar. This forces the output to be sent to me in the form of the cronjob mail. This is a nice built-in notification that the backup succeeded (or failed and the message will inform you). I look at these message *every* morning. Only takes a second or two, and I get the warm & fuzzy feeling that the system is safe for another 24 hours.

Automation is good, and notification is his best friend.

Post a Comment

Your email is never published nor shared.