Restoring application settings from rsync backup

We all know that iTunes will generally restore your application settings and documents after an upgrade. But if you are jailbreaking and restoring fresh, this rarely goes very smoothly. I prefer to have iTunes sync all my apps from scratch and not touch the backup, then restore the documents and preferences for each app.

For Mac OS X, I put together and AppleScript to do this. It is an advanced script that requires some knowledge of shell scripting, SSH, and applescript.

After reading the initial comments, if you want to go ahead, download the compiled application script from rapidshare here. (Because copy & paste wouldn’t compile, I’m just including the comments here. Must download actual script.)

This download is the version for 6/20/2009. (tested successfully with a couple bug fixes.)

EDITS for Firmware 3.1.x: I’ve now run this successfully updating from FW 3.0 to 3.1.2, but the following additional steps must be made:

NOTE for Firmware 3.1.x: rsync must be installed first with Cydia.  It is no longer installed by default.

NOTE for OS X 10.6.x: On Snow Leopard, you need to re-save the script as an Application, as Snow Leopard changed the way Application bundles are saved.


(*
RESTORE APP SETTINGS AND DOCS
by metaclam
https://metaclam.wordpress.com
donations accepted via PayPal at web site above
06/19/2009 (see version history at end of beginning comments)

This script application will restore your documents and preferences folders of all iTunes synched "mobile applications" from an rsync backup of your iPhone to a new iPhone restore.

The assumption is that if iTunes re-installs your applications, they will all have new app ids (the hex strings).
So this script finds the new id and restores the documents folder and the library/preferences folder for each application from the old app id location to the new location.

This script is an ADVANCED script and requires some knowledge of shell scripting and applescript, but not TOO much.
Be warned, it does not do extensive error checking, so watch the log, which by default is set to go to ~/Library/Logs/iPhone_App_Settings_Restore.log

DISCLAIMER:
YOU USE THIS AT YOUR OWN RISK.

To set this up:

#1. You will have first had to run a BACKUP using rsync of your iPhone (before upgrading firmware or otherwise restoring) to a set local directory.
#2. You will need to jailbreak your phone, install OpenSSH from Cydia, etc, and then re-sync all your apps with iTunes.
#3. You will also need to make minor edits to these script properties.
#4. You will also need set up remote SSH login RSA keys on your restored phone.

NOTE: in the following examples I use MY iPhone IP (192.168.0.203) and my local backup directory path (/Volumes/Naga/Archives/iPhone-Backup/).

#1. the command to make a backup using rsync:
rsync --exclude private/var/mobile/Media/iTunes_Control/ -av root@192.168.0.203:/ /Volumes/Naga/Archives/iPhone-Backup/ --delete

This will of course take a long time -- maybe hours depending on how much stuff you have on your phone.
This excludes all your iTunes files which will of course be synched by iTunes itself.

#2. Can't help you much with step #2; if you don't know what all that is, this will do you no good anyway.
Remember you must install a patched mobile installation file if you plan to sync cracked apps etc, and follow relavent directions.

#3. You must edit the first 4 properties in this script as described.

#4. SETUP SSH AUTHENTICATION for ROOT on your iPhone

This is the most tricky part. See this page for details:

http://www.webmonkey.com/tutorial/Automate_a_Remote_Login_Using_SSH-Agent

You will do this after you have set up SSH on your new iPhone and adjusted the root password as necessary (ie, with the "passwd" command via ssh)

In summary, in Terminal you must:

a. create your local user SSH key pair with this command:

-- $ ssh-keygen -t rsa

b. when prompted, save the key in your local user directory as such:

Enter file in which to save the key (/Users/USERNAME/.ssh/id_rsa):

c. then copy the file from your local user directory to your iPhone root directory with this command:

-- $ cat ~/.ssh/id_rsa.pub | ssh root@192.168.0.203 'cat >> .ssh/authorized_keys'

(note, you may need to create the .ssh directory in your root home with 'mkdir .ssh' first)

d. enter your root login password (which is alpine unless you changed it with the 'passwd' command).

VERSION HISTORY
=====
06/19/2009: initial release
06/20/2009:
- fixed searching for apps with spaces
- other bug fixes and tweaks
- tested successfully after restore from FW 2.2 to 3.0!
*)

Advertisements

14 Responses to “Restoring application settings from rsync backup”

  1. chris Says:

    i have successfully jailbroken and unlocked my 3g.

    one problem: i realize that i need some of the data from an app on my jailbroken 2.2. is there any way to access that info? I did make a backup before i started this upgrade process (and it is a different name than my new 3.0 backup). do i have to restore to fresh 2.2, then jailbreak with redsnow and then restore to the previous backup? will the app data be there after all that?? can i selectively restore only the data i need?

    it’s literally 5 bits of info that i need to recover! im such an idiot for not emailing a backup to myself when i had the chance! i was just so excited to upgrade…

    i appreciate any info….and hope this isnt too off topic. it somehow seemed relevant…

  2. metaclam Says:

    If you mean you made a backup with iTunes rather than something like RSYNC, you need a utility to extract the files from the iTunes backup (assuming you don’t want to restore everything from the iTunes backup, which you probably don’t). Personally, I’ve never tried any such utilities but there have been a couple. Here’s one I just found through Google:

    http://supercrazyawesome.com/

    let us know your results if you go this route.

  3. flash-player Says:

    Great post!

  4. Todd Says:

    Thanks Metaclam for the tip about […] I just had to restore something selectively and googled how, came across this site and saw your post.

    The program actually worked perfectly and was very easy to use.

  5. steance Says:

    Hi! What is the difference between those 2 terms, or are they the same thing but with different names? thanks!

    ________________
    world of warcraft warlock guide fap turbo forex robot NetcCom iphone 3g unlock how to unlock iphone 3g

  6. greg Says:

    I backed up my iphone 3.1.2 with rsync and need to restore it. do I execute the rsync command on the iphone and point it to the iphone root to replace the entire file system with the backup. Is this what your script does.

  7. metaclam Says:

    greg, please read the above directions carefully — it should explain what it does. it will NOT restore the whole file system, it is meant to restore the documents and preferences files for each iTunes-installed app, but restore them to the NEW location for that app after installing fresh copies of all apps via iTunes.

  8. Simon Says:

    Hello,

    nice post. Can you send me the script via email, because all slots at rapidshare are full at the last 2 hours.
    Is there a easy way just to restore only the prefs of some of the apps.

    Thanks in advance

  9. metaclam Says:

    Sorry for the very late reply. You can exclude any apps by keywords in the properties. Just try rapidshare again (assuming its not too late.)

    Note some additions I just made at the top relating to 3.1.x.

  10. Some notes on upgrading from scratch « Box of Clams Says:

    […] script I wrote to upgrade to 3.0 still worked great, with a couple of additional steps for FW 3.1 and Mac OS X 10.6, as […]

  11. Play app sounds from Mac rsync backup « Box of Clams Says:

    […] So I wrote What’s That Sound.  What’s That Sound is an AppleScript that will find all the sound files of extensions that you choose (.aif, .aiff, .mp3, .caf, etc) that are located within the .app folders of your iTunes-installed applications.  It doesn’t read directly from your iPhone, but rather from an rsync backup of your iPhone file system on your Mac. (It’s based on this script to restore app settings and documents from an rsync backup.) […]

  12. Ajzimm3rman Says:

    well done. very impressed.

    Wish I had ssh access automatically without jailbreak -bypassing the whole itunes deal on restore initially.

  13. metaclam Says:

    I just cancel when iTunes gets to the restore phase. Then install Cydia apps, then install iTunes apps fresh (with iTunes), then run this.

  14. A Rocky Road to iOS 5 Untethered « Box of Clams Says:

    […] and documents even if it gets interrupted during the initial restore process. This makes the script I wrote to restore app settings/docs from an rsync backup no longer really needed as long as this continues to work. But better to always make a full rsync […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: