We’ve been using BackupPC as our home backup system for the last year or so, and it’s done a great job. It runs under Ubuntu on the home server (an Eee box) and backs up the various family laptops to a RAID array composed of two 1tb USB drives. For offsite backup, we now have a couple more USB drives that receive weekly archives from BackupPC and are swapped to and from my office. For the first time, I feel like we’re doing a decent job taking care of the family digital jewels.

Recently I’ve been looking at the content we create and store on external services. We’re all on Facebook, my daughter and I have five active or at least non-defunct blogs between us, I tweet. Why not archive all that as well? The pleasure I’ve been getting from reading my grandparents’ papers will, for our posterity, depend on this stuff. Not to be morbid, but read last week’s New York Times article “Cyberspace When You’re Dead”. Personal digital archiving is important, and we need to learn to do it properly. The Internet Archive is sponsoring its second conference on the subject in a few weeks.

I’ve started with Twitter. This has forced me, finally, to write some Python, in order to use the OAuth libraries necessary to authenticate to the Twitter API since they turned off basic authentication last summer. Jeff Miller’s tutorial, which uses the Tweepy module, got me going. Once you’ve got the authentication working, the demo script allows you to publish tweets from the command line, which is cool, but… Trying to think of a use for it, my mind went back to BackupPC and the need to monitor its actions and notice when backups aren’t working. It sends email notifications, but why not get them in the Twitter flow as well? It’s the perfect place for short notices.

So, our server now has its own Twitter account. BackupPC provides hooks for scripts to run at different stages of its various processes. To send a tweet after a backup job, add this to the configuration file for a host:

$Conf{DumpPostUserCmd} = "/home/backuppc/bin/post.py backuppc: $client $type: $xferOK"

This will send a tweet in the form “backuppc: cheetah full: 1” (where cheetah is the host, the backup was full, and it completed successfully – 0 indicates a problem).

The script post.py is based on Jeff Miller’s example. I modified it to compose the tweet by concatenating all the command line arguments (to avoid the use of quotation marks, which I couldn’t get BackupPC to handle properly no matter how I escaped them).

#!/usr/bin/env python

import sys
import tweepy

CONSUMER_KEY = '*********************'
CONSUMER_SECRET = '*********************'
ACCESS_KEY = '*********************'
ACCESS_SECRET = '*********************'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

# drop first arg, which has name of script
args = sys.argv
args.pop(0)
tweet = ""
for arg in args:
	if tweet != "":
		tweet += " "
	tweet += arg

api.update_status(tweet)

All for the thrill of seeing tweets like this:

BackupPC tweet