Fast, clean and reliable iPhone backups

As iPhone users know, iTunes’ backup facility is sketchy at best; It can corrupt backups, it can be ridiculously slow, and on a personal note; I don’t like the idea of “trace files” creeping into a newly restored device.

So I’ve decided to outline a “workflow” I personally use whenever I’m up for a restore session. Everything here assumes a jailbroken device of course.

How it was before

On a 2.x device, the way you could get your AppStore apps’ settings restored was by using iTunes’ backup images – buggy as it is. There’s also the issue of bugs during normal usage; there have been cases of legitimate apps randomly crashing – and the only “cure” was to erase the app and reinstall it. This would’ve been fine, only they forgot to mention that when you erase/uninstall an app, that’s exactly what you’ve done – along with all its data.

That same nuance applies to jailbroken apps as well; doubly so, since there practically isn’t any automated way of doing it. With official AppStore apps, at least you can try your luck and use iTunes’ crappy method. On the jailbroken side you literally have to SSH to the phone, hunt down, and manually copy files/folders 1 In different locations to “backup” a setting of an app you want “backed up.” And we’re only talking about settings here; you’d still have to re-install every single one of those apps after every restore.

Thankfully in my case, this pain in the tooschie isn’t as pronounced. Ever since the AppStore, the jailbroken apps I use through Cydia are limited to system administration and such; most of them are of the generic (“switch on/off” type) persuasion – so they require minimal or no “configuration.” That eliminated the whole need for backing up settings; which only leaves us the “manual installation” part to deal with.

Pwnage Tool

Thankfully, there’s a program out there that allows you to build a custom .ipsw file. 2 For simplicity’s sake, just consider the file as a “disk image” of an iPhone/iPod Touch OS’s base install; Whenever you restore, it uses these images and flashes your device with their contents. What this implies is that you can “preload” your device with 3rd party applications as part of the restore process. This naturally solves the hassle I mentioned in the previous paragraphs. It also is a huge timesaver; because iPhones/Touches download at a much slower speed than your desktop – so save yourself the wait by just having them pre-installed into the device right off the bat.

AppBackup

This is a jailbroken app that can backup/restore AppStore app settings into one folder. For those who’ve ever tried backing up such apps manually, I’m sure you’ve seen what these apps’ folders look like: /var/mobile/Applications/E81FD8D9-225D-4C6A-91E5-A513B654401E or something similar. Very obscure indeed – try “hunting” file settings that way.

AppBackup makes short work of that and does all the searching for you; then dumps all the backups into a single folder.

Putting it all together

Given the stuff (and caveats) at our disposal; here’s an ideal flow of tasks we need for a clean restore… ending up with restored application settings. To avoid confusion, I’ll call Apple’s (iTunes) restore process “reformatting” and “restoring” is the actual restoration of [user] data.

  1. Backup AppStore app settings to desktop (via AppBackup)
  2. Reformat device normally using custom .ipsw (to pre-install jailbroken apps like AppBackup) and sync/install AppStore apps back into the device.
  3. Put backed up AppBackup files back into jailbroken device and restore them (via AppBackup)

The only caveat here is that you lose your Global Settings 3 The settings you usually set through the “Settings” application such as network passwords, etc. That sort of thing. and some data from the default Apple applications (Clock, SMS, Weather, etc). Also, interestingly enough, it doesn’t provide backing up of jailbroken app settings 4 Which doesn’t hurt to have in case you’ll need it too. Hopefully the author of AppBackup would include provisions for those in the next version.

The Process

Now lets get to the meat of the matter. What exactly do I do when I undertake a reformatting session…

Preliminaries: Have everything you need ready

Nothing sucks more than finding out in the middle of a reformat that you’ve missed something that can make you lose your data. Personally, I check for these before going through reformatting.

  1. On the device: make sure you have the following installed (and working):
    • OpenSSH
    • AppBackup
  2. On the desktop side:
    • Device has been synced with desktop I can’t stress this enough; a lot of people worry about their contact information, calendar stuff, etc. But if you just sync it to your desktop before doing a restore session, you can always just have the desktop overwrite the device – which means if both were synchronized right before, you should be set.
    • Make sure you can actually access the phone via SSH
    • Have your custom .ipsw file configured and ready

Building an IPSW via PwnageTool

As of this posting, for my purposes, here’s the skinny on what packages I need pre-installed on my phone. I won’t bother getting into detail about the nuances of Pwnage Tool or Cydia, but sufficed to say I’ll just assume you know how the fundamentals of each.

The packages in red are the absolute minimum required for Cydia to run. These are installed whether you include them or not when building your .ipsw – assuming you’ve chosen to include Cydia in the install options. The benefit of manually checking/downloading them however, is that it makes sure you use the most recent versions of each package – it’ll save you a lot of time. 5 Because if you just stick to the default install, and it so happens that a bunch of packages have been updated, you might have to sit through a long update process.

The light red ones I believe are also installed by default; I still marked them differently because you can delete them if you’re really anal about diskspace. I strongly suggest you leave them there however; they only amount to about 9MB anyways – hardly a show stopper for a multi-GB device.

The gray packages are optional, but what I personally install for whatever useful reason I have (e.g. openSSH – which you’ll be needing at some point)

Lastly, the packages in blue, just like those in gray, aren’t needed for Cydia to run, but they are needed for AppBackup to run, so make sure you include them as well.

  • adv-cmds
  • APT
  • Automatic SSH
  • Base Structure
  • Bourne-Again SHell
  • Berkeley DB
  • bzip2
  • Classpath
  • Core Utilities
  • Cydia Installer
  • Cydia Community Sources
  • Darwin Tools
  • Diff Utilities
  • diskdev-cmds
  • Debian Packager
  • XML Parser Toolkit
  • Find Utilities
  • Gawk
  • gettext
  • GNU Privacy Guard
  • grep
  • gzip
  • inetutils
  • Link Identy Editor
  • less
  • ARM Floating Point
  • libffi
  • libgcc
  • libresolv
  • libutil
  • libxml2
  • Mobile Substrate
  • MobileTerminal*
  • nano
  • New Curses
  • network-cmds
  • New Vi
  • Darwin CC Tools
  • OpenSSH
  • OpenSSL
  • pcre
  • PyObjC
  • Python
  • readline
  • rsync
  • sed
  • Setup Tools
  • shell-cmds
  • SQLite v3
  • Sudo
  • system-cmds
  • Tape Archive
  • UICaboodle.py
  • unzip
  • zip
  • Requires SpringBridge package installed from BigBoss’s source.

Aside from the default Telesphoreo source, here are the other repositories/sources I also include in my Cydia install (as of 08.08.31):

  • BigBoss’s Source (required since AppBackup is located there)
  • ModMyiFone’s Source
  • ZodTTD’s Source
  • Nik’s Source
  • Ste’s Source
  • iSpazio’s Source
  • iClarified’s Source
  • Hack&Dev Team Source

Step 1: Backup via AppBackup

Simple enough, launch AppBackup, and backup everything.

Step 2: Transfer backup files to desktop

Access the device via SSH and copy the /var/mobile/Library/_AppBackup_ folder (and all its contents) to your desktop

Step 3: Restore device with your custom .ipsw

You did all the preliminaries right? So you should still be able to follow at this point.

Step 4: Setup your device as a new device and configure the other areas

Remember, we don’t want the “file clutter” that may be present in an iTunes backup, so don’t restore via an iTunes backup image. Just start from scratch.

If you synced the device like I told you in the preliminaries, it should be a matter of just checking boxes here and there and selecting that using that special area in the “info” tab to force iTunes into overwriting your device with (hopefully up to date) data from the calendar, contacts, etc.

You also want to start installing the AppStore applications you want through the “Applications” tab.

Do a sync and continue to step 5

Step 5: Restore AppStore data

Just do the reverse of steps 1 and 2; access the phone via SSH again (again, you should be able to if you followed the preliminaries and have SSH installed)

At this point, I’d suggest you run AppBackup first and do a backup just so it initializes everything properly (and so you can see if it works properly before putting back the data)

If everything is in order, exit AppBackup (restart the phone just to be on the safe side) then access the device via SSH.

Overwrite the /var/mobile/Library/_AppBackup_ folder with the one you backed up. And you should be able restore the data the next time you launch AppBackup. Personally I just overwrite the files inside the /var/mobile/Library/_AppBackup_/tarballs folder.

You’re done!

The next time you launch any of your AppStore apps, you shouldn’t have to reconfigure them anymore.


Some people (myself included) experience the “password” bug after a jailbroken reformat (usually triggered by the EDGE toggle in BossPrefs) The symptom of the bug is that you can never get mail because the authentication fails, and you can’t log-on to a network.

You can fix that by accessing the device and setting the permissions on the following folders:

chmod 777 /var/Keychains chmod -R 777 /private/var/Managed\ Preferences/

I just suggest you do all this before you try/use the EDGE toggle just to be on the safe side.

Notes

Notes
1 In different locations
2 For simplicity’s sake, just consider the file as a “disk image” of an iPhone/iPod Touch OS’s base install; Whenever you restore, it uses these images and flashes your device with their contents.
3 The settings you usually set through the “Settings” application such as network passwords, etc. That sort of thing.
4 Which doesn’t hurt to have in case you’ll need it too.
5 Because if you just stick to the default install, and it so happens that a bunch of packages have been updated, you might have to sit through a long update process.

Have a say

This site uses Akismet to reduce spam. Learn how your comment data is processed.