Sunday, 4 October 2009

Restore from iPhone backup

3GS jailbreak is now out. I have just updated my phone and done a restore using iTunes. Needless to say this leaves a lot of junk left around. So I decided to restore again and set up my phone as a new one. I synced all my music, apps, vids and, as expected, none of the application save data was available.

So to the restore script. If you made a backup using the script below (and done all) you can run the following script to restore your data).

Run as:

./restore.sh 20091002

Where the 20091002 is the date folder of your backup. This is the first cut of the script, so its just to get the data onto the phone, it will be integrated into the main script. You will need to alter the IP to that of your iPhone:

#--- START ---

USER=mobile
IP=192.168.2.3
export SSH="ssh -i ./iphone ${USER}@${IP}"
export SCP="scp -r -i ./iphone ${USER}@${IP}"
export SCPR="scp -r -i ./iphone "
export SCPS=" ${USER}@${IP}"
SOURCE=${1}

for file in $( ls -1 ${SOURCE} | grep \.app )
do
    APP=$( echo ${file} | sed 's/§/ /g' )
    RDIR=$( ${SSH} "cd /var/mobile/Applications/*/${APP}/../ 2> /dev/null ; pwd" )
    if [ ${RDIR} != "/private/var/mobile" ]
    then
        echo "Restoring ${file}"
        ${SCPR} ${SOURCE}/${file}/Documents ${SCPS}:${RDIR}
    fi
done

for file in $( ls -1 ${SOURCE}/Media )
do
    echo "Restoring ${file} "
    ${SCPR} ${SOURCE}/Media/${file}/ ${SCPS}:/var/mobile/Media/
done
#--- END ---

http://pastie.org/641700

No comments: