6.19.2009

iPhone Backup information/note

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.


References


Inside iPhone Blog: iPhone Backups series

7.30.2008

AppStore freeware roundup

Recently, I found several useful/interesting applications in AppStore. And, they're all free. There are two well-designed games, Labyrinth LE and BreakClassic. The former features tilt control to lead a steel ball passing a wooden labyrinth. There is a commercial version, which costs $6.99, providing 500 stages instead of 10 in the free edition. The latter is a classic brick breaking game features really good graphics. If anyone doubts the graphic computing ability of the iPhone 3G, he/she should take a look at this game.

Besides games, I also download productivity applications such as 1Password, YouNote, and Convertor. 1Password helps you keep login/account information of websites. YouNote allows you to create any kind of notes (text, voice, draw, even with geolocation infos). Convertor is very useful when I want to convert my weight from pounds to kilograms. Note: Convertor is no longer free; it costs only $0.99 tho.

Last but not least, there finally exists a universal IM client! It's named Palringo. With a clean interface, I can now access IMs like Windows Messenger, AIM, and Google Talk anytime, anywhere, no need to worry about the company internet blocking policy. But it's not perfect. First, you have to register a Palringo account (free to register). Second, there is just one contact list that contains all buddies in different IMs. Third, you can't choose to login only Windows Messenger or AIM, once you fire up the application, it'll automatically login all the IM accounts. I'm still looking forward to Fring showing up in AppStore or through jailbroken installers. For now, I'll say Palringo is an OK option since it crashes often on my iPhone...

Invisible Shield Installation


Even before I bought the iPhone 3G, I pre-ordered the invisible shield for iPhone 3G. However, after I got my shield, there are two noticeable lines on the front coverage due to the package. I was kind of pissed and requested a replacement. Yesterday, the replacement arrived and this time I am well prepared for the installation (even watched several video clips on YouTube, try searching "iPhone 3G invisible shield" and you'll get a bunch of useful demos).

To prevent fingerprints, I wear plastic gloves (like those used in surgery). I sprayed plenty of the shield solution on the film before applying it. One good thing about spraying excessive shield solution is that you can adjust the position of the film on the iPhone directly. The front coverage is quite easy to install. For the back coverage, I must admit I'm not 100% satisfied with my work. I should have washed my hands again before applying the back film to avoid lints on the glove (those lints end up adhere to the shield...) The back part is really hard to align, I try positioning the top first but still got a little miss-alignment. Since the new iPhone has a curvy back and corner, I have to utilize the "palm technique" to make the film flat. Overall, it's a nice product that requires a lot of patience and deft fingers.



As for the result, there are no bubbles/noticeable lints on the front but quite a few lints on the back (I know, it is really sad...) If mine were a black iPhone 3G, those lints would not be that obvious. And I think the invisible shield looks better on black models because it can make them brighter. For the white ones, however, the back seems to be less bright than it used to.

7.21.2008

iPhone 3G 使用心得

說真的,這隻iPhone規格不是頂漂亮 (拼規格口水戰首推iPhone 3G v.s HTC Diamond),可是有些小地方,真的很貼心,來談談這陣子使用下來的感想,我很小氣,都沒有花錢買軟體,所以只測過免費軟體。


首先是AppStore相對熱門的遊戲類別,Aurora Feint這個game是must have!!! 有一天我下午專心coding了三小時,可是午休的時候沒睡覺著迷的玩這個game玩了40分鐘。而喜歡DDR的人可以體驗一下TTR (Tap Tap Revenge),以免費遊戲而言,這兩款的質感與耐玩度都十分高。

儘管公司網路擋掉所有的IM,我仍很少在iPhone上用web-based的IM,因為web-based很不穩定,如果有專屬的IM client (例如AIM),狀況可能會改善很多。Safari配合google.com/m(Google mobile版),已經漸漸改變我閱讀的習慣,在iPhone上的Google Reader預設只顯示標題,有興趣的主題我再點進去看,可以有效率的擷取新知(?)。再來就是Weather,早上出門前會看一下氣溫決定穿著,我設定了LA與El Segundo兩個地方,因為上班的El Segundo靠海,高溫往往低約五度。Map有個鍵可以按一下就將地圖定位到自己目前所在地,結合Google Map show traffic,每天下班去健身房跑跑步做重量後我都會check一遍,決定我上路的時間點,另外最近因為在看房子,地圖有一步步導覽(Google Map directions step-by-step zoom-in)對平常有記路名習慣的人來說,已經很足夠了。2MP的相機,在光線充足的地方,拍出來的照片還算ok,看房子的過程中我會隨手拍個幾張紀錄。

此外我還抓了一個meal splitter,可以計算這餐如果有人有喝飲料有人沒喝,那每個人該出多少,還可以設定小費的百分比,算是無腦人外食的方便計算機。可以隨時隨地上網之後,真的想到什麼東西都可以順手查,雖然所費不貲,就趁暑假享受一下等開學再把data plan退掉吧 XD

目前想要購買/下載/使用的軟體有:

  1. Nally for iPhone - it's simply a must

  2. TranslateIt! (剛剛發現了WeDict,試用後再來報告)

  3. MSN for iPhone (dedicated client plz)

  4. Terminal for tethering & hacking (jailbreak + openSSH可做到,越獄猶豫中...)

  5. Where 加強版 (Where的gas buddy很遜,只找得到特定幾家的加油站,可是概念很棒)

  6. Gmail client (push mail & tag feature support plz)

  7. nike+ toolkit for iPhone (那我就去買個arm band來戴,這暑假我變慢跑控了)

  8. US TV guide (我很訝異在AppStore搜尋tv出來的只有瑞士跟紐西蘭的guide...)

  9. Simple Comic for iPhone

  10. AnySync (這是我自己亂想的,因為我很討厭目前的Sync模式,限制太多,理想中應該要自己想要本機上的什麼檔案在iPhone上,用拖拉的方式就過去)

  11. Copy-n-Paste (沒有這個真的很不方便,尤其是現在打字要一個字一個字按很慢...)

  12. Chinese Input Method (iAccess 讓我期待中)


其實iPhone還有很多改善的空間,可是,怎麼說呢,他就是一個會帶給你樂趣的gadget :)

How to get a contract free iPhone 3G in US

Based on my experience solely...

After making several phone calls to 611 (AT&T customer service number if using a cell phone), I got following results.

  1. In 30 days of your purchase, you have to return the phone if you want to cancel the line without paying Early Termination Fee (ETF). However, you can keep the phone and pay the ETF instead, which is exactly what I did.

  2. If you cancel the line within 3 days of the activation, AT&T has to waive your activation fee. The representative said that I don't need to pay the bill for first month either. However, I haven't have a chance to check my mails to see whether it's true. The line activated on the purchase of the phone is proved to be inactive.

  3. I'm currently under an AT&T family plan. I called the representative to add the 3G data plan for $30/mo. I was given two version of answers on this deal. One said that I have to keep this data plan all the way till my contract expired. The other said that the data plan can be canceled anytime.

  4. These could all be done through dialing 611 (AT&T customer service) from your cell phone, no need to rush to Apple/AT&T store.

  5. Different representatives give different answers, I talked to 4 AT&T representatives and ONE Apple sales, so be patient and keep trying...


iPhone 3G rocks, contract-free? even better :-)

iPhone 3G Launch Party

iPhone 3G,從6月初的WWDC發表的時候就開始期待,直到7/11,她終於上市了,我當天下班就跑去Century City的Apple Store想探消息,聽說要排隊三小時,無奈晚上有聚餐,只好隔日再戰。

隔天下午,趁著同學們去看Hancock的空檔,我加入了拿號碼牌瘋狂近乎愚蠢的隊伍中。一開始似乎是拿到448號,當我排到途中在跟朋友通電話時,隔壁的大陸同胞聽到我講中文,問了我一個有趣近乎愚蠢的問題:請問3G, 16g, 8g有什麼差別?聽到差點沒傻眼,居然連這個都不知道的人也來湊熱鬧排隊買iPhone。於是我回答完他的問題後,興起好奇心問他為什麼要買iPhone?他說他是要買帶回去大陸的。我接著問他知不知道要簽約才能買,他果然不知道,後來我陪他去Apple Store求證(因為他說要我陪他去,如果不能買,就把號碼牌讓給我)。於是,我前進到405號,在等待了約莫兩小時後,被帶進Apple Store。

當天Apple Store管制得很嚴格,即便你不是要買iPhone的,也得排隊一一詢問目的才放行。然後iPhone的購買是一對一服務,我相信店員們一定都累壞了,聲音完全表露疲憊,可是還是盡責的一一解釋與回答我的問題。在排隊途中就聽說16g black機種快要完售,不過我心中早已設定要買16g white,所以並不擔心。我覺得白色的背面比較chic,而且,不像黑色款容易沾指紋。我很迅速的以開一條新line的方式,花了$299+tax購買了我的第一隻iPhone(tax的部份很tricky,不是用優惠價$299計,是用$499計...)

下一步,就是好好的與我的新寵iPhone 3G培養感情。