The Backup Plan

WATCHING:
Sideways
Starring: Paul Giamatti, Thomas Haden Church, Virginia Madsen, Sandra Oh

With Church’s wedding coming up, the divorced Giamatti – a vinophile – decides to take the groom-to-be for a tour of the wine country in Southern California.

However, once the trip begins, it’s apparent that Church has a very different idea of what this last getaway will entail. He just wants to party; Giamatti just wants to drink.

Church is the guy who really doesn’t have a lot going for him – he’s an ex-soap actor who is now reduced to doing commercial voice-overs. Yet he always lands on his feet – he’s coated in Teflon.

Giamatti the the exact opposite: An English teacher pretending to be a writer (who can’t get his book published), divorced, he is really just a wine lover to give himself an excuse to drink. He stops by to visit his mother just so he can steal money from her.

I re-watched Sideways this weekend, and I remembered it as funnier. It does have some great comedic moments, but overall this is a very sad movie.

In one of the best scenes in the movies, Giamatti explains to Madsen why he loves pinot noir, and as he discusses the grape etc, you realize he’s not talking about the wine/grape, he’s talking about himself. Very poignant.

All movies

No, not the crappy Jennifer Lopez movie.

It’s about finally getting around to rewriting some backup scripts on my home boxes, so if a hard drive does go down, it’s only a little painful.

I have – mainly – two Linux boxes and a Windows machine. The latter is my primary box for work; the Linux boxes are servers and used to host local versions of my web sites (development environments), as well as a host of homegrown tools I’ve built over the years to help populate my web sites and so on.

I’ve had backup scripts in place for a decade, but I really haven’t revisited them for some time.

This week, I spent some time deleting some scripts, modifying others and creating new scripts. All to reflect how my environments have changed over the years.

Here’s what I’ve come up with:

Windows box:

  • There are two areas of this box – photos and documents – that need backing up. Two scripts, each with the same basic algorithm:
    • FTP to backup folder on Linux box
    • FTP all appropriate files (i.e., for photos, .jpg, .jpeg, .gif, .png, .psd etc.) to this backup folder.
    • Using those same file-type params, zip into a YYYY-MM-DD.zip file.
    • Delete all non-zip files.
    • Get list of all zip files, ordered by date descending. Keep first 10 zips; delete any others.
  • This could work for X areas; same concept, just change directories and and so on.

Linux boxes

  • On each Linux box, there are multiple directories and a mySql database to backup. The backups I perform use the first Linux box as backup for the second, and vice-versa: Data swap
  • mySql backup – Here my concern is just restoring the DB if the hard drive goes south. History is not an issue.
    • On first Linux box, hotcopy all files to a mysqlbak directory.
    • FTP into second Linux box; loop over databases and copy all files from mysqlbak to remote mysqlbak-firstbox directory.
  • Document directories – there are a handful of directories that I want backed up each day, including those directories that hold tools, web roots and so on. For each the process is the same:
    • Tar up given directory to YYYY-MM-DD-[backup name].tar
    • Gzip this tar
    • FTP this GZ to appropriate directory on Windows box (larger drive; also has RAID).
    • Loop over GZ files in this Windows directory, keep last X .gz files.

Is this a lot of work for something I might never need?

Absolutely!

Will it be worth it if I have to recover something – even once?

Absolutely!

One part of my backup scheme that I tested this time was something inspired by a guy named Boris whom I once worked with. He said something like, “You don’t need backup, you need recovery.” I.e., you can have all the backups in the world, but if you can’t recover them, well, what good are they? Sage advice; I’ve worked at more than one place with backups that…could not be recovered. Ouch.

So I wrote some test scripts to “recover” my data. (Docs and databases)

Damn. It all worked.

Perfect system? Nah.

But better than I had before: More robust, more redundant and I can now sleep knowing that what I have backed up can be recovered.