How to backup your iPhone address book
Yesterday, I got burned bad by a Mobile Me sync.
It had rendered my address book from ~400 contacts
down to 6, and had synced this to all my computers.
Only my iPhone contained an un-tainted version, albeit missing
a few lesser used address groups.
I had a mobile me backup from Oct 6th, but i had created many new
contacts since.
So here’s what i did to fix it.
=========
I didn’t want to sync
the iPhone yet though, as i wanted to make sure i could backup its address book
properly.
First, i had to go hunting.
There are a variety of was to do this; you could use the iPhone app
“Finder” (which is excellent, just make sure to switch on hidden files) OR
if you have a jailbroken phone like I do, SSH in to it.
Here’s where I found the iPhone address book database location:
((this is in the iPhone directory structure)
/User/Library/AddressBook
In that directory were two files (both sqllite databases):
AddressBook.sqlitedb AND
AddressBookImages.sqlitedb
Using the Finder.app iphone program, navigate to that directory, and email
yourself both databases (or copy them to another location). Now, you have a backup.
Using the SSH method, simply SCP said databases to a location of your choice on your
computer.
========
Now that my address book was safe, i decided to see what would happen if i syncd
my iPhone; sure enough, it blew away all my iPhone contacts with the 6 from the failed
mobile me sync.
So i restored my computer’s address book thusly:
======================
(the location of the address book data is ~/Library/Application Support/Address Book/
I simply replaced the file
AddressBook-v22.abcddb , which is the database.
This restored my contacts list to the Oct. 6th backup.
=======================
Next, i replaced my now tainted iPhone contact list with my backup.
I simply moved my copied AddressBook.sqlitedb via SSH to the iPhone path
(/User/Library/AddressBook)
=======================
So with my proper iPhone address book back, and my October 6th restore on my computer,
it was time to sync the iPhone again.
Everything worked properly, with a full merge of my newly created contacts on my iPhone.
Score one for the good guys!
=======================
The moral of the story is, mobile me sync has been good lately so i’d become lazy about
my backups.
I just wrote a CRON’d RSYNC script that will bakcup my address book data every other day :).
Happy restoring!