Backup script for jailbroken iPhone

25/08/2009 21:24 | iPhone | 1 reply | 1295 views | RSS

I recently upgraded my iPhone 2G to an iPhone 3G, and because I like to upgrade, I’m upgrading my iPhone 3G to a 3GS! Hell yeah!

Anyway, I don’t like that backup feature of iTunes much (seriously, why does it have to take thát long?), and I have read some horror stories about that backup draining your battery. So I searched on how to manually backup all the important stuff from your iPhone. Important stuff such as SMSes, addressbook, favourites, notes etc …

This is the result of that search … a backupscript! Duh!
Although it is command line only, I do think this will come in handy for at least 3 or 4 people out there…

Worth reading before launching it

  • Only works on a jailbroken iPhone 2G, iPhone 3G or iPhone 3GS
  • Must have OpenSSH, network-cmds and Core Utilities installed through Cydia
  • Does not yet backup Applications and photos, that is a too large amount of data, I’ll create another script for it

How to use?

  1. Edit the $SERVER variable to whatever hostname and user of your box
  2. Use WinSCP to create a new directory /private/var/backup and put the file there.
  3. Chmod it to 700
  4. Now use MobileTerminal on the iPhone or Putty from your desktop to launch the script (hint: “./backup” )

To do!

  1. Cron the bastard so i’ll create a backup on a regular basis
  2. Some sort of management, delete old backups and such
  3. Auto login crap with public and private keys and stuff see here.

Code

#! /bin/bash
# iPhone backup script (c) 2009 sldr
 
### creating filelist
FILELIST="
/private/var/mobile/Library/AddressBook/AddressBook.sqlitedb
/private/var/mobile/Library/AddressBook/AddressBookImages.sqlitedb
/private/var/mobile/Library/CallHistory/call_history.db
/private/var/mobile/Library/SMS/sms.db
/private/var/mobile/Library/SMS/sms-legacy.db
/private/var/mobile/Library/Safari/Bookmarks.plist
/private/var/mobile/Library/Safari/History.plist
/private/var/mobile/Library/Notes/notes.db
/private/var/mobile/Library/Maps/History.plist"
 
### setting up variables
BCKFILE="`hostname`-`date +%Y%m%d`.tar"
SERVER="selder@derelict.weyland.be:iPhone-backup/"
 
### creating archive
tar cfP $BCKFILE `echo $FILELIST`
 
### sending archive
scp $BCKFILE $SERVER

Very special thanks to _bs!


  1. On 22 March 2010 at 15h57, anonymous wrote

    Great info and script, however for me I had to use SFTP with a batch file (only works with autologin) covered here too I think:

    sftp -b put.batch $SERVER

    “Some sort of management, delete old backups and such” – an easier way could be to just:

    rm $BCKFILE

    at the end so if you add other dirs the tarball could get BIG!

    Thanx again!