Backup

August 28th, 2006

I don’t trust computers to not suddenly explode and destroy everything I’ve ever created, and I’ve discovered what I believe to be the easiest and most foolproof way to backup my code, or other things for that matter. Email it to yourself automatically.

I use Subversion to manage my personal code library on a remote server, and since my goal is to always have everything important exist in two separate places, I have a compressed dump of the entire repository emailed to myself weekly. I delete the older versions, but since my email account has plenty of free space it’s not very urgent. This all seems straightforward, but I had to do a lot of research to find the right program to use, which I am now sharing with you. All you need to do is set up a cron job like this…


0 6 * * 0 (svnadmin dump ~/svn/repo/ | gzip --best > ~/svn/repo-backup.svndump.gz) 2>&1 | mutt -s 'repo-backup.svndump.gz '$(date +\%m/\%d/\%Y) -a ~/svn/repo-backup.svndump.gz youremail@email.com

Obviously, replace the path to the repository and the email address to correct values, and put the backup file somewhere too. This particular job is scheduled to run at 6am on Sunday morning. The repository (~/svn/repo) is dumped and compressed (using gzip, at the highest level of compression) to the file "~/svn/repo-backup.svndump.gz". I use mutt to send the email with the file attached. The subject is the name of the file and the date the email was sent (to avoid grouping backup emails together). I also want messages that svnadmin outputs (which contain information on what was dumped, and possible error messages) to be the body of the email, but svnadmin sends the messages through stderr while mutt receives the body of the email through stdout. To fix this stderr is redirected as stdout after stdout has been used to compress the dumpfile. Isn’t Unix great?

Anyway, if you use Gmail, besides a lot of space to manage these backups, you can also make the process easier using plus-addressing. Let’s say your email is "bob@gmail.com", then set the email address in the example to "bob+backups@gmail.com". Set up a label called "Backups" in Gmail and a filter which automatically labels emails as "Backups" when they have been sent to "bob+backups@gmail.com". You can keep them out of your Inbox if you archive them with the filter as well.

Some other important things…

  • Keep in mind there are size limits for attachments in emails, but this isn’t much of a problem as long as your repository stays fairly small (and full of text files).
  • You don’t need to send them to one address, check the manual page for mutt for more information.
  • Using bzip2 rather than gzip would be a better idea, as bzip2 has recovery features if something goes wrong, but currently Gmail has a major bug when viewing emails with bzip2-compressed files attached. These emails are improperly handled and won’t open through Gmail.
  • I prefer to use a svnadmin dump since I won’t be making any commits at exactly that moment, but more active repositories should probably dump a copy of the repository using svnadmin hotcopy instead as a safety precaution.

The future of computers

August 25th, 2006

Amazon is onto something. It’s like a VPS on steroids. I’m not joking when I say that this is the future of the Internet hosting, or more accurately, computer processing in general.

I get my feed updates via Gmail (it’s a long story) and I got this one two weeks ago. I was planning on posting it right away, but then I figured it’d be in bad taste if the world actually ended on August 22nd. Boy would my face be red! Be sure to the sidebar.

Speaking of Boing Boing… FC64 got boingboinged.

Browser history bug

August 22nd, 2006

This is clever. You know that links using the CSS :visited pseudo-class change if you’ve visited the linked page. Did anybody think of using that to tell where you’ve been? It’s so obvious now. I imagine several browsers will issue fixes for this down the line, probably by denying the use of :visited for other domains.