Monday, February 18, 2008

Manual backup and restore of data for iPhone upgrade to 1.1.3

You can restore Contact List Calendar Entries, if you sync them in iTunes before upgrade, however, some third-party application data cannot be sync if you use jailbreaked phone.

This will illustrate how to manually backup of iPhone third-partly application data before upgrade and how to restore the data after upgrade.

Assume using Mac and SSH is installed in iPhone

(1) Backup /var/root before upgrade (make sure iPhone Auto_Lock is Never, the backup will take over 45 minutes)
In Mac Terminal
ssh root@192.168.0.11 "cd /var/; tar -cf - root | gzip -c" > ./iphone_backup_root.tgz


(2) Extract it using command in Mac Terminal
tar -xzvf ./iphone_backup_root.tgz


Restore (assume your iPhone has IP address of 192.168.0.11
In Mac Terminal

# restore lighttp Sites
pushd root
scp -r root/Sites root@192.168.0.11:/var/root/
popd


# restore VNotes's recording
scp root/Library/Recordings/*.amr root@192.168.0.11:/var/mobile/Media/Recordings/


# restore camera photos
scp root/Media/DCIM/100APPLE/IMG*.* root@192.168.0.11:/var/mobile/Media/DCIM/100APPLE/


# restore YouTube bookmarks
scp root/Library/YouTube/Bookmarks.plist root@192.168.0.11:/var/mobile/Library/YouTube/
ssh root@192.168.0.11 "chown mobile:wheel /var/mobile/Library/YouTube/Bookmarks.plist"



# restore Safari Bookmark
scp root/Library/Safari/Bookmarks.plist root@192.168.0.11:/var/mobile/Library/Safari/
ssh root@192.168.0.11 "/usr/bin/chown mobile /var/mobile/Library/Safari/Bookmarks.plist"


Shell script to restore Notes (run in iPhone)

assume you have /var/root/bin/sqlite3 in iPhone
or get it here

#/bin/sh

fw113db="/var/mobile/Library/Notes/notes.db"
fw111db="/var/root/backup/notes.db"

/var/root/bin/sqlite3 -line $fw111db '.dump Note' | grep -v -E "(^CREATE*|^DELETE*|BEGIN$|END;$)" > fw111notes.sql
/var/root/bin/sqlite3 -line $fw111db '.dump note_bodies' | grep -v -E "(^CREATE*|^DELETE*|BEGIN$|END;$)" >> fw111notes.sql

/var/root/bin/sqlite3 -line $fw113db '.dump Note' | grep -v -E "(^CREATE*|^DELETE*|BEGIN$|END;$)" > fw113notes.sql
/var/root/bin/sqlite3 -line $fw113db '.dump note_bodies' | grep -v -E "(^CREATE*|^DELETE*|BEGIN$|END;$)" >> fw113notes.sql

cp $fw113db ./notes_backup.db
/var/root/bin/sqlite3 -line $fw113db '.read fw111notes.sql'

2 comments:

Samson said...

Beside the user data, is it possible to create a FULL backup of the complete iPhone3GS/iPod Touch3 root file system partition(s) and restore later on? I am just thinking since Apple is no longer allow restore OS 3.1.2 if we can at least maintain a tarball of the whole existing OS then we can just simply restore the full system by ourself in case things go wrong...

jack hill said...

This will illustrate how to manually backup of iPhone third-partly application data before upgrade and how to restore the data after upgrade.
unlock iphone 3gs tutorials