How to Restore Your Contacts from Titanium Backup Pro

Mike1989

New Member
Joined
Aug 10, 2014
Messages
3
Reaction score
0
Current Phone Model
Galaxy Note 2
If you don't already know, Titanium Backup is an app that lets you easily restore different apps and data that you had on a previous ROM. When you install a new custom rom, you have to wipe the phone. Titanium saves the data you want to transfer in a special folder and when you install the new rom, you can easily restore your information from Titanium.

However, contacts are not something you can transfer easily from Titanium.. even if you made a backup in the first place.

For most of you, it's likely your contacts are synced with Gmail and you won't really have to worry about getting them from Titanium.. but for some of you, if you're like me... you don't sync with Gmail contacts.

This presents a problem when you're installing a custom rom and you want all of your contacts.

The contacts2.db file is a database file. Inside of this file is a unique format of database that is accessible to other files and programs. We need to read this information, translate it into a different format your phone can use.. which will be VCF.

Here's how:

Make sure you still backup your contacts before installing your custom rom with Titanium Pro. We will need the backup file it stores.

Use DROIDEXPLORER to explore your phone and navigate to the folder of the Titanium Pro Backup. Typically, this is just in the internal SD storage. It will be something along the lines of sdcard/0 in the main folder.. or you can get to it by starting from the root of the phone, and going to "storage" then sdcard.
Note this is NOT the external sd card, but one built into the phone.
*This may be different on different models.. but if you've gotten this far I'm sure you won't have a problem finding the actual file of the backup Titanium Pro created.

These files will be compressed files like .gz or .tar. There will be 2-3 of them that have file names starting with com. and the word 'contacts' in the file name. You can't really miss them.

Copy these files to a local destination on your computer of your choice.

Extract them. Most of the data you find in there you won't need. Once you extract all of them, look for a folder named "data" which has located within it another 2-3 folders named "data". Keep navigating until you see a file named "contacts2.db".

This is the only file we need. Save it somewhere you'll remember.

Next, you need a linux terminal.
Use UBUNTU. Download it onto a bootable disc or USB from the main website and have your computer BOOT from this source. When it loads, you can use UBUNTU as a demo and not install the full version.

Create a folder anywhere on the UBUNTU hard disk for you to do some work.
From UBUNTU, you can still navigate to your windows files.
Navigate to wherever you saved contacts2.db and copy/paste into the location on UBUNTU.

You will need to download a script.
https://github.com/stachre/dump-contacts2db

Click the dbconverter.sh link and copy and paste the source code you see.
In the same location where contacts2.db is, right click in UBUNTU and create new empty file.
Open it up, paste the code, save the file.
Make sure to rename that file to dbconverter.sh.

Open up terminal (control + alt + t).

Make sure to navigate to the folder that you just made.
Start to do this first by writing ls (short for list).
This will tell you what directory you're in and what folders are in your location.

Navigate to each section by writing CD sectionname replacing the sectionname with whatever folder you're trying to navigate to.

Keep searching until you're in the folder where you have your contacts2.db and dbconverter.sh included.

Once there, we need to download some resources for the code.

type in
sudo apt-get install sqlite3 libsqlite3-dev

Wait for these to download and complete.
Once done, tell Ubuntu that the dbconverter.sh file is an executable by typing
chmod +x dbconverter.sh

Finally, execute the script.
./dbconverter.sh contacts2.db > contacts2.vcf

Wait for it to complete. VCF file will be placed in same folder you've been working in.
Copy the file and paste it somewhere in your windows folders since you can't access these locations in Windows.

Restart into Windows... get the VCF file on your phone.. open the file in ES File explorer and use Contacts as app to open it up.

It will load all of your contacts.

One issue is many contacts may repeat themselves. For this, sync your contacts with GMAIL.. login to GMAIL, go to contacts, select all contacts, and select the option to merge duplicates.

Resync on your phone.
 
Last edited:

BHuber09

Super Moderator
Staff member
Joined
Feb 1, 2011
Messages
64
Reaction score
32
Location
Atlantis
Current Phone Model
Note 3
Twitter
@BHuber09
I use to have the same problem a while ago. If you go into the contacts app -> menu button -> import/export -> export to SD card. Then it'll back all your contacts up in .vcf on your SD card so after you flash you can do the same steps except click import and bam. All your contacts are right there.


Not sure if this method works across all devices however i know it worked back I'm my droid X days and works currently on my Note 3.

Note'd
 
OP
M

Mike1989

New Member
Joined
Aug 10, 2014
Messages
3
Reaction score
0
Current Phone Model
Galaxy Note 2
Absolutely you're right..
This would only be if you didn't do that or didn't sync with GMAIL and depended on titanium and already had flashed new ROM.

As long as you can locate the database file for contacts, it'll work.
 

Loomingx

New Member
Joined
Feb 6, 2016
Messages
1
Reaction score
0
Current Phone Model
S4
I followed these steps and while I was able to create a .vcf it was 0 bytes.... I received no error typing the commands. I'm on Ubuntu 15.10 booting of a usb. Could this be the issue?
 

miluardo

New Member
Joined
Feb 9, 2016
Messages
2
Reaction score
0
Current Phone Model
Galaxy S5
Twitter
hiatthe
I followed these steps and while I was able to create a .vcf it was 0 bytes.... I received no error typing the commands. I'm on Ubuntu 15.10 booting of a usb. Could this be the issue?

It would come from either a corrupted .db file; or one that is not in a recognized format.

Also.. you're a noob.
 

n00by99

New Member
Joined
Feb 2, 2017
Messages
1
Reaction score
1
Current Phone Model
Sony Xperia C4
Thanks for posting this! I've been looking for this since I'm in a similar situation.

So, perhaps because of my phone model, I couldn't find any contacts2.db file. Here are some differences:

1. My backup folder was on my external SD card and not in my internal storage. I tried searching if maybe TiBu saved some files on my internal as well, but it didn't.

2. The file that ended up being relevant to me was called:
com.sonyericsson.android.socialphonebook-DATE-TIME.tar.gz

3. When I extracted it, it was pretty much /data/data/com.sonyericsson.android.socialphonebook/ then four folders. The only ones with any .db files was the one called "databases," so it seemed like I was on the right track. However, as you can see below, when I tried the script with each of the four files, I got an error. I'm guessing it's probably the .db-journal files that have my contacts but are just encrypted by TiBu.

USERNAME@SERVER:~/Documents/Contacts$ ./dbconverter.sh google_analytics_v4.db > contacts2.vcf
Error: no such table: raw_contacts
USERNAME@SERVER:~/Documents/Contacts$ ./dbconverter.sh google_tagmanager.db > contacts2.vcf
Error: no such table: raw_contacts
USERNAME@SERVER:~/Documents/Contacts$ ./dbconverter.sh google_tagmanager.db-journal > contacts2.vcf
Error: file is encrypted or is not a database
USERNAME@SERVER:~/Documents/Contacts$ ./dbconverter.sh google_analytics_v4.db-journal > contacts2.vcf
Error: file is encrypted or is not a database

Note: Every one of those commands resulted in a .vcf file that was 10 kb and completely empty except for "END:VCARD."

I use to have the same problem a while ago. If you go into the contacts app -> menu button -> import/export -> export to SD card. Then it'll back all your contacts up in .vcf on your SD card so after you flash you can do the same steps except click import and bam. All your contacts are right there.

I wish I'd known about this earlier. This seems like a really easy fix I could do twice a week with a calendar reminder. I guess I'll do that from now on. Thanks!
 
Last edited:
Top