Friday, January 13, 2012

How to Restore Lost Contacts to Your iPhone

I believe this is the only place in the internet you can find accurate information on how to restore your CONTACTS. There are many guides out there and posts but they are either incomplete or wrong, mostly due to misinformation. I actually figured this out randomly... Usually this is the case for good things in life : )

I stumbled upon this blog looking how to restore my backed up contacts.

I followed the 2 methods posted there and neither of them worked for me. The issue seems to be that every time I was copying over the Addressbook.sqlitedb over I could see the contacts in both Phone App & Contacts App but as soon as I pressed Home button, the Apple logo showed up with a progress bar and after that, the contacts vanished and were empty again.

I tried MANY things. None seemed to work. It was frustrating since I thought I was so close on every attempt...


(1) You need a (backup) copy of your contacts that you want to restore. Your best bet is to locate the following file name inside iTunes backup folder: 31bb7ba8914766d4ba40d6dfb6113c8b614be442 The path for this file in a Windows XP system is C:\Documents and Settings\[YourUserName]\Application Data\Apple Computer\MobileSync\Backup I'm not too sure what is the right path on Windows-7 [please double check] but it could be C:\Users\[YourUserName]\AppData\Roaming\AppleComputer\MobileSync\Backup. Just make a copy of that file and place it somewhere else. Rename it to AddressBook.sqlitedb

Alternatively you may have a copy of the contacts file that you got in the past from accessing your iPhone's file system. You can access that file if your device is Jailbroken by browsing the raw filesystem using a file browser utility like iPhoneBrowser or i-FunBox. These are freeware utilities. Run a Google search and download one of them. These are very useful to mess around with the iPhone/iPad file system and they allow you to do different things like backup copies of your Apps, install new Wallpapers, ring tones, etc. You should be very careful about messing around with files in general or deleting any stuff. If you screw up you may end up having to restore your device. By following this guide you should be ok, we are not doing nothing funny here, but just be warned.

The contacts file is stored in /var/mobile/Library/AddressBook/ and the file name is AddressBook.sqlitedb. There is also another copy in /var/root/Library/AddressBook/ but I'm not too sure what that one is being used for. Initially I thought one was used by the Phone App and the other by the Contacts App but that is not the case. Also note that many people incorrectly talks about a different path being /private/var/... It is actually the same file accessed (mounted) through a different route. This is a Unix thing if you are not familiar with Unix file system...

You also need a freeware tool called SQLite Database Browser. SQL is a database format. You don't need to know much more about it. The important thing to understand is that your contacts information (name, phone numbers, email) is stored in a particular format which is accessible using that tool. For example, you could access your contacts information with it and generate a CSV (Excel) file which represents the info as a tab separated list with commas, allowing you to import the contacts info into some other device (if you ever change your phone by an Android one..) or software like Outlook. There are specific guides and software to assist you in that process which is out of the scope of this guide, but I encourage you to Google them if you want further info.

You should be able then to open that file with SQLite Database Browser. There are several fields containing the relevant information like names, phone numbers, emails, etc. I won't go into detail as it gets complicated.

(2) If you are trying to restore the contacts from a different iOS (Firmware) version you also need to copy the empty contacts from your current file system. WHY WE NEED THAT? Long story short, if you open the contacts file with SQLite Database Browser, and go to 'Browse Data' tab there is a field named '_ClientVersion' under '_SqliteDatabaseProperties'. We would need to match the version number in that field for the old backup of AddressBook.sqlitedb with the current version in your iOS, otherwise the process will fail and the contacts won't get restored. This is the main point of the whole process and it seems to be what people is missing in other guides available in the internet. YOU CAN SKIP THIS STEP IF YOUR ARE RESTORING CONTACTS FROM SAME FIRMWARE/iOS VERSION.

(3) now open the backup copy of your AddressBook.sqlitedb with your contacts and edit that field to match the same version number in the current iOS. Save the file! (update it).

(4) FINALLY copy over the updated copy of your AddressBook.sqlitedb to both /var/mobile/Library/AddressBook/ and /var/root/Library/AddressBook/ (just drag it from the location you have it on your PC and drop it [inside the iPhone browser application of your choice, i-FunBox/iPhoneBrowser...] in the path mentioned above, and you should see the contacts in your Phone App and Contacts App right away, no need to reboot or anything!

I spent a few days until I got this right. I honestly don't know much about the iPhone but I have become an 'expert' by just browsing the net and figuring out things by myself. So I encourage people to do so and learn. There is a bunch of crap out there... and it is up to us to filter it and seize the good stuff. Good luck!


Zain Mastron said...

Thank you so much! This actually worked after many hours of trial and error!

I had to downgrade the girlfriends phone from 4.1 back to 3.1.3 due to the the iPhone being so slow.

The only bug that is still current is that the address book thinks all the names are numbers. But still sorts them by alphabetical order. Strange.

ORM said...

Thanks for your guide but I can´t get it to work.

I've upgraded from 4.3 to 5.0.1 and saved my the AddressBook.sqlitedb on my harddrive. The Client Version of that database is 35.

However I cannot figure out the client version of the existing one. I've copied the AdressBook.sqlitedb from Root Directory/var/mobile/Library/AddressBook to my harddrive, but when I open it with SQLite nothing shows; no data, fields or anything. The file seems to be empty.

Any idea what I´m doing wrong?

Ragnhild said...

Hi, hope you can help me.. Ive been googleing my ass off, but cant seem to find out whats wrong. Ive located the backup file with all my contacts (i can see some of the contact names in between all the codes), and ive uploaded it to SQLite database browser, but i cant seem to find the contacts on there. i can see the number of contacts, but it doesnt show under “browse data”. am i doing something wrong, or is there just no way for me to extract my contacts from that file? Hopefully someone knows what i can do! A million thanks in advance!!

Jaime said...

Dear Ragnhild

if you open the file with any text editor and you look for "_currenversion" you will see the magic number. But don't try it, because anyway these method it's not enough right now, at least with IOS 5.1 on Iphone 4

An Spaniard from Murcia, working in the Vega del Segura, SALUDICOS!

DarkPsy said...

I was restoring my address book backup from the same OS version, It is the same, I even checked the old backup and the new file's currentversion, it's 16 . When I open my file it shows a string of numbers and names encrypted, but when i paste it in my iphone it does not work.

I have even tried exporting it to csv using the following query

select ABPerson.prefix, ABPerson.first,ABPerson.last, ABMultiValue.value from ABPerson,ABMultiValue where ABMultiValue.record_id=ABPerson.ROWID

it returns no results in sql lite manager, is there a possibility that my backup is corrupt, even though i can open it in notepad and see everything?

Would appreciate any kind'f help.