Sunday, September 2, 2007

Bacula to the Rescue

It finally happened - disastrous data corruption.

My mail client of choice - Icedove (the debianized Thunderbird) - started crashing for no apparent reason. It took me a few crashes to figure out that one of my email accounts was probably corrupted somehow - Icedove would crash whenever I tried to get messages for it. It even crashed when I tried to simply select its Inbox folder (I wanted to move the messages to a different folder and then delete and recreate the account).

This was definitely the right time to try bacula for real:
  1. Select "Edit->Account Settings..." menu item in Icedove's menu
  2. Find the bad account, record the path of the "Local directory" under "Server Settings"
  3. Exit Icedove
  4. Run bconsole - the bacula command console - in a terminal
  5. Enter the command restore and follow instructions to select the appropriate backup job that should be restored (I picked the latest)
  6. Eventually the command console will enter file selection mode, where you can mark files and directories to restore (hit ? and <Enter> to get a list of available commands). Select the files under the directory recorded at step 2 above.
  7. Run the restore job. Files are restored to a restore directory, so that there's no risk of overwrite.
  8. Replace the content of the bad mail directory with the restored files using

    cp -a <restore directory>/* <bad mail directory>

It's really that easy.

No comments:

Post a Comment