February 3rd, 2008

Time Machine

Apple's "Time Machine" backup solution is simple. A bit too simple. So simple, in fact, that it doesn't actually work right in a pretty common situation unless you're a clever hacker. So much for being easy for dummies.

Let's say, for example, that you have gotten your computer repaired, and thus have a new motherboard. The next time you try to back up your machine with Time Machine, you'll find that it wants to do a whole new "full" backup, which of course doesn't fit, due to the existing full backup already on the drive.

So, how do you make Time Machine do an incremental backup of the same hard drive you had before, now that it's in a new computer?

After a bit of fiddling around, I figured out that it stores the ethernet address of the machine you backed up, and that's how it figures out which backup directory to use. Where does it store it? A extended attribute of course.

$ cd /Volumes/james\ backup/ 
$ xattr -l Backups.backupdb/James\ Knight’s\ Computer/
com.apple.backupd.BackupMachineAddress: 00:1b:63:1e:77:4c

Looking at ifconfig en0 | grep ether shows that it should be 00:17:f2:f1:42:ad. So, let's just set the attribute...

$ sudo xattr -w com.apple.backupd.BackupMachineAddress \
 00:17:f2:f1:42:ad Backups.backupdb/James\ Knight’s\ Computer/
[Errno 1] Operation not permitted: 'Backups.backupdb/James Knight\xe2\x80\x99s Computer/'

Hmmmm, interesting, can't modify, even as root. I'll save you the random flailing I did next, and get right to what works (and I really have no idea what kind of insane-o permissions scheme does make the following work...)

$ sudo mv Backups.backupdb Backups.backupdb2
$ sudo xattr -w com.apple.backupd.BackupMachineAddress \
 00:17:f2:f1:42:ad Backups.backupdb2/James\ Knight’s\ Computer/
$ sudo mv Backups.backupdb2 Backups.backupdb

All done! Just unmount and remount the backup drive, and time machine will properly recognize it again. Now if only Apple had thought to key backups off of some identifier on the actual volume being backed up, instead of the machine doing the backing-up. Doesn't seem like rocket science, does it?