How to get application data from the iPhone
If you’ve written any kind of non-trivial application from the iPhone, you’ve had to deal with debugging it while not in the debugger. Sometimes you may even need to get at the preferences file and other support files, such as “saved state” files to see what went wrong.
There are two main ways to go about retrieving application data for your iPhone applications, depending on whose phone you want to get it off of. If it’s your personal phone you do development on, it’s pretty easy. If you need to get data from someone else, like say a beta user, it’s much more involved.
For your iPhone
If you’re on your development machine and iPhone, Xcode provides a pretty simple way to get at the data.
-
First, dock your iPhone, then open Xcode.
-
In Xcode, open the Organizer, via the Window > Organizer menu item.
-
Select your iPhone in the source list on the left.
-
On the right, locate the Applications list. Find your application, and disclose the disclosure triangle to the left of the name.

-
Select “Application Data” underneath the name of your application, and press the button on the right, the down arrow image.
-
You will be prompted for a place to save it. Pick a place, and press “Save.”
You now have your application data onto your Mac, where you can debug it. You can either go to the Finder to browser it, or it is also added to the Organizer window in Xcode, under the “Projects & Sources” tree.
For a beta tester’s iPhone
If you are running a beta and you need to get data from your application to debug, things get pretty tricky. The general idea is you get your beta user to find the iTunes backup files (yes, more than one) that contain your application data, and have them send them to you. Then, using a third party python script, you uncompress the backup files, and hope that they actually contain the correct files.
-
First, if the user does not yet have a backup (unlikely), they should force one. Do this by selecting the iPhone in iTunes, right clicking (or control-click) and selecting “Backup”.

-
Next, the beta user should open the Finder and go to ~/Library/Application Support/MobileSync/Backup. With any luck, there will be one folder here, which will be the 40 character hexadecimal device ID of their iPhone. Navigate inside this folder.
-
In the Finder, switch to list view and sort by modification date.

-
At this point, your beta user needs to select the appropriate backup files that contain the data you need (haha). Depending on your user, you may want them to just zip up the entire folder and send it to you. Be warned though — it’s huge.
To be more selective, you only want the files ending in “mdbackup.” These files can be grouped based on modification date. For example, in the screenshot above, you can see that a backup happened Today, at 5:06 PM. The beta user could select all of the mdbackup files with a modification date of “Today, 5:06 PM”, zip them up, and email them to you.
The thing to note here is that iTunes only does incremental backups. If your application data has not been modified since the previous backup, the current backup will not have your data in it. So you may need to repeat this step several times with your beta user until they find the right backup.
-
At this point the beta user should zip up the “mdbackup” files, however you had them select them, and email them to you.
Things are now in your, the developer’s, hands. You need to convert the mdbackup files into something you can use.
-
First, download iphone-backup-decoder from Google Code. iphone-backup-decode is a Python script that will unarchive all those mdbackup files you now have.
-
Next, make a directory that you can work in, called “Backups” (or whatever you want to call it). Place all your mdbackup files in here, and move decode_iphone_backup_v2.1.py file here as well.
-
Before you can run the python script, you need to make it executable. In Terminal.app, cd to your “Backups” folder, and type the following:
chmod a+rx decode_iphone_backup_v2.1.py -
You are now ready to run the decoder, by typing in Terminal:
./decode_iphone_backup_v2.1.py *.mdbackupThis will unarchive all mdbackup files current in the “Backup” folder, so keep that in mind if you’re going through multiple backups.
The results should now be in a folder called “MobileSyncExport” inside your “Backups” folder. If you are very lucky, it will contain the files you need.
If you need to repeat these steps, I would advise deleting all the mdbackup files and the MobileSyncExport folder from your Backups folder. The decoder script will most likely give undesirable results if you decode two backups that contain the same file.






14 Responses
On Aug 21st 2008 06:26 pm, scott said:
thanks Andy! worked like a charm.
On Aug 29th 2008 12:55 am, Enrico said:
Andy, you are a lifesaver. An iPhone hiccup led me to lose several recordings and the app that created them, until I used your methods on an older backup (and managed to find them per your directions). I guess Terminal isn’t that scary after all…makes me want to use PINE again!
On Sep 8th 2008 04:34 am, Pascal said:
Hi Andy, THANK YOU SO MUCH!! Misbehaving iphone coupled with new baby resulted in a silly me restoring phone without grabbing photos first! Realised with horror that there were quite a few early shots of our latest family member lost to the digital neverland. I’ve never opened Terminal before but your article here is perfectly written as I was able to retrieve these photos with ease.
Big love from from the UK ..
-Pascal
On Sep 14th 2008 11:31 am, Juan Daniel said:
Hi Andy!! Wow, your instructions saved me…After updating iPhone FW to 2.1 I had problems restoring from a backup, so I ended up with a “new” phone…I knew there had to be a way to get some of the things back: i mostly cared about pictures. Me, being a complete novice in OSX (use windows myself) could go through your instructions without a problem, and after a few minutes was getting a copy of all the pictures!
Besides that, I could find .plists for a few apps I had lost information from…now I can retype that easily!!!
THANK YOU VERY VERY MUCH
(keyword:restore pictures from iphone backup)
On Sep 14th 2008 05:28 pm, ravenofdoom said:
Seeing as I don’t have a mac (and don’t have the “console” you’re referring to), is there an easy way I can apply this script on a PC?
On Sep 15th 2008 07:19 pm, jfriah said:
what if you aren’t on Leopard?!?!?!
On Sep 28th 2008 07:26 am, Jon said:
Thanks for much for this info, you’re a lifesaver. Had a bunch of pictures of the kids on my iPhone, which broke. This worked like a charm and was able to get all of the pictures back. Thanks!
On Oct 5th 2008 11:38 am, james said:
can anyone help me, i managed to extract the backup folder from my files but i am clueless on how to get back my photos and notes
please email me. helpp…
regards
On Oct 13th 2008 01:01 am, H. Locher said:
@james: just follow the steps above, you will find a directory media/dcim/100apple which should contain your photo’s
@andy: thank you very much for the detailed information, I just managed to recover my photo’s!
On Nov 7th 2008 07:10 pm, Padraig Kennedy said:
Hi Andy,
I’m the author of the iPhone Backup Decoder script that you have linked to above. I have just released a Cocoa based GUI tool that does the same thing as the script, but is far easier to use and would thus greatly simplify the steps above.
Let me know what you think of it: http://supercrazyawesome.com/
Cheers,
Pádraig.
On Feb 24th 2009 04:24 am, UziMean said:
hi Andy,
Is there a way to recover the sms messages from a backup stored in my local computer (windows).
Here is what i did:
I created a profile, synced and backed up, then i upgraded the Iphone OS, after the new OS I plugged the iphone and it asked me to chose the ‘previous owner’ or to use the phone as a ‘new owner’…. i chose the new owner (to be on a safe side)… but since i created a new owner now i dont see the previous owner profile name anywhere and when i sync i do not get any sms and any contacts or anything from the previous owner at all…. i do not see on the iphone profile list as well under Itunes advance settings …. now when i connect the iphone I see only the new user profile….
I have a backup… I tried various method like these ones
http://lukhnos.org/blog/en/archives/99/comment-page-1#comment-30304
http://insend.de/index.php
but no luck at all… i am freaking frustated…
This was my plan:
1. Sync and backup the iphone with the itunes.
2. Upgrade the iphone OS using different method(not via the itunes)
3. After the Successfull OS upgrade, sync with the itunes and get all the previous data and everything back…
What happened?
In above process, step 1(sync) and 2(OS upgrade) went successfully, in step 3 when i connected the iphone it gave me an option to choose the previous owner profile or use it as a new phone, I chose to use it as a new phone…after this I cannot see the previous owner profile or get anything from the previous profile…. which means all the previous sms and contacts and everything is gone…
The most imp was the sms. I have the backup file for sms but extracting the sms from that backup has not been a success so far… any help from any developer would be a life saviour….
On Mar 7th 2009 02:47 am, Spencer said:
Wow, Hope u can help me. I was syncing iphone to new Mac. I wanted to get all of my photos on the Mac. My iphone had been previously synced with my old PC. I noticed when I synced to my new Mac it did not sync previous pics synced from P.C. Before the syncing was complete I forgot and lifted my phone out of the cradle and broke the connection. When I put the phone back, it had a disconnect error and it extracted all of the photos off of my iphone. When this happened I panicked and hit the restore. I don’t know where my photos are or if I’ve lost them. I need help, if thats possible
On Aug 31st 2009 01:30 pm, Helen Hunt said:
This is a very good hack for accessing the device. Worked like a charm for me.
Thanks for posting it
On Oct 27th 2009 10:34 pm, Felipe Navarro V. said:
Very useful http://supercrazyawesome.com/!! (iPhone firmware 3.1.2)
Thanks for posting this.
Fe.