Yesterday’s Thoughts

September 12, 2005

Snapshot Backups

Koz has a little whoops moment and deletes his installed application code.

So, say you’ve typed in:

$ sudo rm ruby gem irb rails

Then you realise you’re sitting in /usr/bin rather than ~/test/bin. You think to yourself, no worries, I’ll just kill that whole line. But instead of hitting C-k, you miss, and hit j.

I’ve been using emacs for around 7 years, and until this morning I didn’t know that C-j is the same as hitting enter. 2 hours later, I have a functioning rails install again.

Whoops! This could have been much worse, but it could be better. (Actually Koz must have used rm -r at least.)

I have been doing hourly snapshot backups for the past couple of month. I recommend it to everyone. The system that I am using should work on any Linux or BSD (including 0S X) system. It could probably be made to run on Windows, it only requires rsync and Perl, and you could probably configure in as a set of Scheduled Tasks. I’ll leave that as an exercise for the reader. I’d appreciate any tips actually, especially if you can configure the Scheduled Task by command line.

I use rsnapshot and backup my entire development system to a separate hard drive. There is a detailed description here. The process is simple enough, you install rsnapshot, edit the configuration file to specify which files you want to backup and where you want to back them up, and then set up a set of cron tasks to do the snapshots.

I take a snapshot every 4 hours, every day, every week, every month, and every year. At any time I can have up to 6 hourly backups (a whole day), 7 daily backups, 4 weekly, 12 monthly, and 5 yearly. rsnapshot uses hard links so that it doesn’t have to keep an actual copy of every file, only every changed file. Since I only started a couple of months ago, I only have 2 monthly backups and no yearly backups, but currently I am using less than 15 G to keep 19 backups of my 7.5 G of system files, configuration, code, and database files, subversion repository, web sites, personal files and Mail.

The security of being able to recover anything, at anytime is a terrific safety net and increases my confidence when making any change.

In Koz’s case, if I hadn’t changed anything in a week I would have been able to do
% cd /backup/weekly.0/usr/bin % cp -pr ruby gem irb rails /usr/bin
and been back to work in a couple of minutes. Plus, any hard won customizations, configuration changes, patches, etc. would have been preserved.

By the way, Koz’s problem isn’t with emacs. C-j is the ASCII code for linefeed (0x10). Any ANSI terminal program should do this. Other codes that could get you in trouble at the command line are C-m (carriage return, 0x13), C-i (tab, 0x09). C-l (formfeed, 0x12) may clear your screen.

C-g (0x07) will ring the bell.

2 Comment(s)

  1. Koz | Sep 12, 2005 | Reply


    Given that I work for a company which provides secure online backups, you’d think I backed up my laptop. But no.

    Having learned my lesson, I’ve setup my mac to rsnapshot my whole drive to my Strongspace account.

  2. Ray | Sep 13, 2005 | Reply


    Ouch. There’s some parable about shoemaker’s children needing shoes that would seem to apply here. Glad it worked out.

Sorry, comments for this entry are closed at this time.