(SOLVED) Backup your iPhone using rsync

Mobile Support
Post Reply
User avatar
Admin - Founder
Admin - Founder
Posts: 2916
Joined: Sat Jul 19, 2003 12:00 am
Location: Wangaratta, Australia

(SOLVED) Backup your iPhone using rsync

Post by ADF-Sniper »

Difficulty = Advanced

I thought I would let you know how to backup your iPhone using RSYNC to a Windowz box. I store some pretty useful data on my mobile, if I was to loose it, the world would end.

What I want to achieve is...
A Scheduled cronjob (Scheduled Task) to execute rsync (Synchronous my mobile to my home Computer) every hour. Maximum loss of data is less then one hours worth. This is also good way to help retrieving your stolen phone :)

Ok, so first we must do is have a SECURE rsync server running.
I installed COPSSH on my Windowz 7 Box.

1. You can download it from here.

2. When you install on Windowz set the username as "root" and set your password!.
Now SSH on your Windowz box should be up and running.

3. Next you will need to create a user "root". Open COPSSH Control panel click users tab and press Add, now add the user "root" Apply and OK.

4. Download and unzip RSYNC.EXE from here
into this folder.
C:\Program Files (x86)\ICW\bin for 64bit users or
C:\Program Files\ICW\bin for 32bit users.
Now rsync.exe is installed, your almost there.

5. You will need to generate a ssh key for your iPhone to login to your PC without prompting for username and password. To do this download putty from here...
http://www.chiark.greenend.org.uk/~sgta ... nload.html
Run putty and enter iPhone's IP into hostname click Open. This will allow you to connect your your phones SSH Server.
First time connect will ask you do you trust the SSH server... Click Yes.
Now use your iPhones username and password you setup when you installed ssh on your mobile, default is user "root" and password "alpine".

6. Generate the ssh key, this gets a bit confusing for me but ill hopefully get it in the right order :) From inside you SSH Connection type the following without the talking marks
"ssh-keygen -t rsa" and keep pressing enter at the prompts until finished. Well done you just setup a SSH key on your iPhone :)

7. Now your iPhone's got a key, we need a lock for it to open. So lets create a lock to suit the key.
To do this you will need to create a file called "authorized_keys" on your Windowsz 7 machine.
FTP to your iPhone using a FTP client, I use Filezilla. Navigate to
and copy the file to
C:\Program Files (x86)\ICW\var\.ssh
Now rename the file that is in C:\Program Files (x86)\ICW\var\.ssh from "id_rsa.pub" to "authorized_keys"
That's it Done! Now you can SSH from your mobile to your PC without a password :D

8. Now all the Windowz side of things are setup time to mess with your iPhone YAY!
First we will setup a Scheduled cronjob (Scheduled Task) to run every hour.
FTP to your iPhone again and navigate to...
Now create a new file called "com.syncmyphone.60min.plist"
With the following in it....

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
I'm Pretty sure thats about a hour :)
Now CHOMD or set the file privileges to 644

9. Create the rsync command. Navigate to
"/private/var/root" and create a file called "phonesync"
Put in the following lines...

Code: Select all

rsync -v -r -u /private/var/mobile/ root@
rsync -v -r -u /private/var/root/ root@

rsync -v -r -u /private/var/mobile/ root@IPTOYOURCOMPUTER:/home/root
rsync -v -r -u /private/var/root/ root@IPTOYOURCOMPUTER:/home/root
Ok, to explain the script above the first two are to RSYNC through my local network after that the next two RSYNC will use my 3G connection to sync. I do this so I don't use all my data when I am connected locally.
Now CHOMD or set the file privileges to 744

Here is a example of what I run

Code: Select all

rsync -v -r -u --exclude=/AAA/ --exclude=/Applications/ /private/var/mobile/ root@
rsync -v -r -u --exclude=/AAA/ --exclude=/Applications/ /private/var/root/ root@

rsync -v -r -u --exclude=/AAA/ --exclude=/Applications/ /private/var/mobile/ root@********.dyndns.org:/home/root
rsync -v -r -u --exclude=/AAA/ --exclude=/Applications/ /private/var/root/ root@********.dyndns.org:/home/root

If all correct you RSYNC should be located
"C:\Program Files (x86)\ICW\home\root"
Now please post your thanks for taking four hours to write this and hours of study to get it working :D
If you see any faults please reply, most of it was done from the top of my head, but looks good to me :D
Evolution is just so unlikely to produce complex life forms.

Post Reply