Time Machine: Your Version Control Safety Net

Justin Miller / @incanus77:

Just accidentally blew away 16 files’ & days’ worth of work with hg. Looked up, TIme Machine had just finished. Lost < 1 min. of work.

Time Machine has also repeatedly rescued me from from numerous VCS missteps.

It’s gotten to the point where I want to write a command-line tool that would ensure a Time Machine snapshot before executing the next command:

$ tmnow && git branch -d somebranch

Such a tool should be fairly easy to write – just kick off backupd-helper and block until the ThinningBackup or com.apple.backupd.NewSystemBackupAvailableNotification distributed notifications.

The downside is Time Machine backups tend to take a few minutes to run, so tarballing the whole repo before tricky operations tends to be faster, if a more manual process.

Update Jul 20: Mac OS X 10.7 (Lion) features a tmutil command, which features a startbackup subcommand with a --block option. So my hypothetical tmnow == Lion’s real-life tmutil startbackup --block.

Jul 20 2011