iPhone Backup information/note

http://keepmurmuring.blogspot.com/2009/06/iphone-backup-informationnote.html

Folder location

~/Library/Application Support/MobileSync/BackupFile

  • Info.plist
    Each device's Info.plist file is created by iTunes. It stores your iTunes preferences for that unit along with basic device information.

  • Manifest.plist
    The Manifest.plist file is created by the iPhone backup utility on your computer. It uses this manifest to check files for corruption and (inadvertently, I'm sure) prevent any data changes on the Mac side from being sent back to the iPhone.

  • .mdbackup files
    the mdbackup files are created by the iPhone backup utility. If you delete any of these files, they're re-created the next time you sync and back up.

  • /System/Library/PrivateFrameworks/MobileDevice.framework/ Resources/AppleMobileDeviceHelper.app/Contents/Resources/AppleMobileBackup
    command for manually force a sync or a backup; ambackup is a symbolic link for the command

    ./ambackup --backup --target targetid

    The device immediately backs up to disk. This goes surprisingly fast, even when you've deleted or moved the backup folder. So don't expect it to take a long time.

    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



Read mdbackup files in Cocoa

mdbackup files are property lists and are created in a compressed binary format. These files are just as readable from your Foundation Cocoa programs as any other property list. The key to recovering data lies in de-serializing the data stored in that property list dictionary.

Read mdbackup property lists into your program just as you would read any other plist
[NSDictionary dictionaryWithContentsOfFile:mdbackupath];

This call creates a new NSDictionary object and initializes with the contents of the property list (or in this case mdbackup) file.

Once loaded, you may access the file data from the dictionary. Request the object associated with the @"Data" key 
NSData *data = [mdbackupDict objectForKey:@"Data"];

Store that data out to disk 
[data writeToFile:outfile atomically:YES];


The name of the file is stored in the @"Path" key. Use this value to restore the data to a file with the same name.

Create subset backup files


You can easily strip a manifest of its extraneous applications and files and re-embed that stripped manifest into the Manifest.plist file and restore just that subset. Here are the steps:


  1. Create a new working directory in ~/Library/Application Support/MobileSync/Backups.
  2. Copy the Manifest.plist file and the mdbackups you want to restore into the working directory.

  3. Read in the @"Data" item from Manifest.plist and deserialize it to a dictionary. Remove all the items in the @"Applications" subdictionary and everything but the specific mdbackup files you want to use from the @"Files" subdictionary.
  4. Reserialize the updated dictionary, add it back into the Manifest @"Data" and sign the reserialzed data with SHA1.

  5. Perform a restore using --source as the working directory. Only the selected files will transfer to the iPhone.



Sample Code:

// Read in the file to embed
NSMutableString *embedFile = [NSMutableString stringWithCString:argv[1] encoding:1];
if (![[NSFileManager defaultManager] fileExistsAtPath:embedFile])
{
fprintf(stderr, "File %s does not exist\n", argv[1]);
exit(-1);
}
NSData *pdata = [NSData dataWithContentsOfFile:embedFile];

// Read in the mdbackup file
NSMutableString *mfile = [NSMutableString stringWithCString:argv[2] encoding:1];
if (![[NSFileManager defaultManager] fileExistsAtPath:mfile])
{
fprintf(stderr, "File %s does not exist\n", argv[2]);
exit(-1);
}
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:mfile];

// Add the embedded file
[plist setObject:pdata forKey:@"Data"];

// Serialize the output
NSString *errorString;
// NSPropertyListXMLFormat_v1_0
NSData *outData = [NSPropertyListSerialization dataFromPropertyList:plist format:NSPropertyListBinaryFormat_v1_0 errorDescription:&errorString];
[outData writeToFile:[@"out-" stringByAppendingString:mfile] atomically:NO];


Tools

Erica Sadun's utility to examine and extract backup files
a command-line Mac-based application that scans through backup folders and extracts 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.

iPhone/iPod Touch Backup Extractor
This application converts the iPhone / iPod Touch backups that are created by iTunes into readily usable Mac OS X files. It is designed to run on Mac OS X Leopard only. The current version works with iTunes 8.2 and iPhone OS 3.0 or lower.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值