Advertisement

Mission TUAWpossible: Back up your iPhone with Time Machine

Good morning, Mr. Phelps. The man you are looking at is Justin T. iPhoneuser, one of our loyal TUAW readers. Recently, Justin's iPhone went kablooey and when he tried to restore, he found that his backups were corrupted. He lost a great deal of data and time, all because Time Machine hadn't backed up his iPhone's data.

Your mission, Jim, should you choose to accept it, is to help Justin back up his data with Time Machine so he never has to face this kind of data loss again. As usual, should any of your team members be caught by Apple, the Secretary will disavow any knowledge of your actions. This post will self-destruct in five seconds...

[This is the part where the Theme Music usually plays.]

Read on for your TUAWpossible Mission Briefing.

Mission Briefing

Jim Phelps: Team TUAWpossible has learned that Time Machine doesn't automagically back up iPhone data. iPhone backups are stored in your home folder in Library/Application Support/MobileSync/Backup. The folders in that directory store backup data and their manifests for each iPhone or iPod synced to your Macintosh.

TTime Machine's standard exclusions property list specifically tells TM not to back up those folders. Barney, tell us more about the iPhone backup scheme.

Barney Collier: Thanks, Jim. As you already mentioned, iTunes stores all iPhone backup data to the MobileSync backup directory. Each backup contains a signed version of an iPhone file with a master manifest that adds a further layer of authentication to the process.

The reason that 2.0 backups take so long, Jim, is that the iPhone backs up every user file on the phone. And since all Application data is considered user data, the entire app folder is saved for every onboard application. Clearly, Apple made a misstep here since some Applications have massive data components, which must be synced during each and every backup.

Moving on, the manifest file that appears in the backup folder lists every file that was saved by the iPhone. The manifest is then signed using a secure process that involves but is not limited to SHA-1 encryption.

Jim Phelps: Barney, that sounds complicated.

Barney Collier: Yes, Jim. It sure is. Fortunately, it's relatively easy to scan through those files and recover the backed up data. Download a copy of mdhelper to your Mac, make it executable (chmod 755 mdhelper) and run it from the terminal command line. You can search through your backups and recover, for example just sql databases, e.g. ./mdhelper -C sqlitedb.

Jim Phelps: Cinnamon, stop putting on and taking off that mask (geek humor: & 0xff) and tell us about the exclusion list.

Cinnamon Carter: Sure Jim, let me put away this "Space 1999" write up and talk about that. Time Machine's exclusion list can be found on your Macintosh at /System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist. This file tells Time Machine which files it should not back up.

Jim Phelps: Can I open that up in TextEdit to take a peek?

Cinnamon Carter: It's a property list, Jim. That means you'll be far better served by opening it in Apple's Property List Editor. This is a standard utility that's included with the Xcode distribution package. Alternatively, you can open it in TextEdit if it has been saved in XML format. You can convert to XML from the command line by issuing the plutil -convert xml1 StdExclusions.plist command.

The file, when opened in Property List Editor looks something like this:

Notice the three kinds of exclusions:

PathsExcluded Time Machine excludes certain kinds of paths from backups. These folders include your Spotlight data, the trash, previous system backups and so forth.

ContentsExcluded The kind of content that TM excludes are drivers, caches and logs. These folders refer to system-level utility data that provide no benefit to the user.

UserPathsExcluded UserPaths are those data items that are stored in your home folder. These folders include both caches and logs used by Safari and Mail as well as -- you guessed it -- MobileSync backups. Rollin will tell you how to edit this to remove the MobileSync backup exclusion.

Rollin Hand: Thank you Barbara, er, I mean Cinnamon. To remove the exclusion involves nothing more than editing the property list. However, there is a snag. The property list is a system item with limited editing permissions. You'll need to edit a copy of the file and then replace the original.

  • From the Terminal command line, change directories to /System/Library/CoreServices/backupd.bundle/Contents/Resources/:

  • Copy the property list to the desktop.

  • Double-click the copied version to open it in Xcode's Property List Editor.

  • Select Root > UserPathsExcluded > Item 1. This is a string, the first element of the UserPathsExcluded array. Select it and press the Delete button. Property List Editor removes it from the list. Save your changes.

  • From the Terminal command line, from the backupd.bundle/Contents/Resources/ folder, issue the following commands:

Should at any time you need to revert to the original version of the file, it is now stored in StdExclusionsOriginal.plist.

Jim Phelps: Thank you, Rollin. That's the end of our mission for today. If you've followed along, you'll have now set up your Mac's Time Machine to back up all iPhones and iPod touches. This can be pretty data intensive -- but it might provide a lifesaving backup just when you need it, and save your top-secret organization from those meddling teenage kids.

Thanks, Alexander Burke