Saturday, August 16, 2008

iPhone backups and accesing .mdbackup files

Apple - Support - Discussions - Where does iTunes saves iPhone Back-ups ... ... "The backups are in ~Library/Application Support/MobileSync".

On my system MobileSync/Backup has 3 folders. I think this reflects the tumultuous history of my iPhone and the flopped restore procedure. The name of the folder is the unique identifier of your iPod or iPhone:
To back up an attached device, you must specify its target ID. This is the name used for the folder in the MobileSync/Backup directory...
and the name of the files is ...
... the name of each backup file is actually the SHA1 hash of its path...
When I synched my iPhone 1 of the 3 folders was updated, so the others are either inactive backups or correspond to my iPod. (I think they're inactive backup files.)

My backup folder is 70MB but holds almost 1,400 items. It contains a small portion of my 8GB of iPhone data and apps.

The files end in .mdbackup. That leads to some interesting posts:
The last series is the winner. It includes a post referencing a relatively friendly command line app for extracting data from an .mdbackup file (I've downloaded a copy, you should too - but note that using a command line utility is a non-trivial task. I think you need at least admin privileges and you may need to do more to enable the app to run/):

... You can examine the contents of these files and extract the backed up data from them using my mdhelper utility. It's a command-line Mac-based application that scans through these folders and allows you to extract files. For example, to recover all the png images from your backups, you could issue mdhelper -C png. Run the utility without arguments to see the built-in options...

What mdhelper does is this. It locates all backup folders. It reads in the Info.plist and Manifest.plist files and it lets you extract manifests and files based on a variety of search options. It stores extracted data on your desktop in a recovered iPhone files folder.

Pop back on Monday to learn more about backup files and how to force your iPhone to backup and restore from the Mac command line.

and, when things are really bad, you will appreciate these tips on how to restore from an archive you've made of a "good" backup (I'm sure there will be a GUI tool to do this very soon.):
.. In order to restore a device, you run the AppleMobileBackup program using the restore switch, like this:

./ambackup --restore --target targetid

This throws your iPhone into restore mode and returns any uncorrupted files from the backup folder to your device. This takes quite a bit longer than the backup, so prepare to wait a few minutes for it to complete.

If you want to restore your phone from a folder that is different from the target ID normally used, supply a source folder name as follows:

./ambackup --restore --target targetid --source sourcefoldername

If the source folder is not found in the backups folder, one is created. If it is found, that manifest and those files are used to restore your iPhone...

I've zipped a copy of my latest "good" backup, and retrospect backs up these files too. It's good to know I can, if things are desperate, scrape lost data from these files.

Update 8/20/08: The iTunes Preferences "Syncing" panel lists the backups by name and date. You can delete unwanted backups there. It only lists my iPhone backups.

Update 12/21/10: If you are looking for a particular device backup in a set of backup folders, you need to look for the manifest.plist file in each directory. Open it in a text editor and scroll down. You'll see the name of the device.

2 comments:

Anonymous said...

Desperately seeking a backup extraction tool. My iphone overwrote my bookmarks via mobileme and i have some critical work stuff in there.

The script on the we (perl based) seems to fail after extracting some 3rd part apps.

Any help...GREATLY appreciated!

Anonymous said...

I posted the mdhelper to the folder and then used terminal. Evry time I attempt to use the program it tells me command not found. WHat am I doing wrong.

Thanks for the help.