Tardis repair manualWhere you have an FTL blog, there must be time machines. Apple Time Machine, that is. It provides a convenient way of backing up files without thinking about it, but there are tricks to using it best and mistakes to avoid.

You really should start by understanding how Time Machine stores files. If you look at a Time Machine backup volume that’s been in use for a while, you’ll see a directory called Backups.backupdb. This is the root directory for all your backups. Under it will be a directory named for your computer. If you’re backing up more than one computer to the same drive, they’ll all be listed there. Under that will be some number of directories whose names look like timestamps, and a directory alias called “Latest.” You should see directories for every hour your machine has been on in the recent past, dwindling down to dailies when you go back a day or two, and weeklies when you look at directories more than a month old. There may be gaps, depending on how much of the time your computer is turned on.

If you look under any of these timestamps, you’ll see what appears to be a complete copy of the contents of your drive. Add all of these copies together, and you may find it contains many more gigabytes of data than your whole drive! How does it do this? The answer is incremental backup and the Unix “hard link.” When it does a backup, only files that have been added or changed since the last backup are copied; the rest are just directory links to older backup directories. Unlike an alias, a hard link is a first-class citizen of the file system; for all practical purposes, the file is there, and it’s also where it used to be. A hard link, like a Tardis, lets your files be in two or more places at once. The nice result of this is that if you want to get a particular file or folder back, you just have to find it on the backup volume and copy it.

Older versions of your files, as well as deleted files, are retained in older backups. Eventually your drive will fill up, and TM will delete the oldest backups, so don’t count on it to keep anything forever.

As far as I can tell, Apple doesn’t say what happens if you shut down your computer while a backup is in progress. This help item says, for OS X 10.7, that if a backup is accidentally interrupted, “Time Machine resumes the backup where it stopped.” A test shows that if I shut down during a backup, a file with a name ending in “.inProgress” is left, and a backup directory appears only after the backup is complete. If Time Machine is in the middle of a long backup and need to leave your computer, you’re probably better off letting it finish rather than making it start over.

Knowing how Time Machine works provides some clues about how to use it most effectively. It automatically excludes some files, such as caches, from backup, and you can tell it to exclude more. If your backup drive is less secure than your computer, you might want to exclude files that have serious confidential information. Time Machine handles large database files poorly, since all it knows how to do is make a new copy of a file that’s been changed. They could be another candidate for an alternative backup strategy. But make sure you have some reliable backup; those database and confidential files are probably important, and losing them completely isn’t good security!

With some work, you can have Time Machine back up a database monthly (or however often you like) even if you change it every day. Exclude the database file from backup, and set up an automated task such as a cron job to copy it once a month to a directory that isn’t excluded. Time Machine will back up the copy only when it changes.

Avoid the temptation to delete files from Time Machine. because of the way directories are linked together, you might either lose more than you think or not really delete what you think you’re deleting.

Multiple backups are better than one, and a drive that isn’t usually connected to your computer is safer than one that’s always connected.

These are just a few tips for using Time Machine effectively. To learn lots more, read the articles in the links below.

Suggestions: If you have a Mac, take advantage of Time Machine to automate your backups, but use it intelligently.

Useful links: