[ROOT] Manually backup/restore call history, text messages and contacts

Search This thread

askpcguy

Senior Member
Aug 8, 2010
1,952
189
I been performing this myself with great success, but you need ROOT access AND busybox installed. Create a folder on your phone's SD card called tmp. You'll need adb in order to adb shell, and gain root access. (in cmd, adb shell <enter> su <enter> confirm you are on a # prompt not the $ prompt)

Now copy and paste each line, press enter after each line pasted. Confirm the files copied after each line by running ls /mnt/sdcard/tmp/mmssms.db
Code:
cp /dbdata/databases/com.android.providers.contacts/contacts2.db /mnt/sdcard/tmp/contacts2.db
cp /dbdata/databases/com.android.providers.telephony/mmssms.db /mnt/sdcard/tmp/mmssms.db
cp /dbdata/databases/com.sec.android.provider.logsprovider/logs.db /mnt/sdcard/tmp/logs.db
cp /dbdata/databases/com.sec.android.app.memo/Memo.db /mnt/sdcard/tmp/Memo.db
cp /dbdata/databases/com.android.providers.calendar/calendar.db /mnt/sdcard/tmp/calendar.db
Once that is done, mount the phone to your computer and copy the TMP folder to your computer. When you flash the custom rom, you'll have to keep the SIM card out of the phone because you do not want new history items written to the log files.

Next ls -l /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others) to see what permissions/owner they have, if you simply cp the files from /mnt/sdcard/tmp to their locations, you'll get force closes in the application (because it's not able to write log data).

Make note is the owner for each db file. Then back to adb shell, su, cd /mnt/sdcard/tmp (trust everyone knows to copy the tmp folder from PC onto your phone) cp contacts2.db /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others!).

Once the files are copied back to their locations on the device, run the following:
Code:
chmod 660 /dbdata/databases/com.android.providers.contacts/contacts2.db
chown app_15.app_15 /dbdata/databases/com.android.providers.contacts/contacts2.db
Obviously you want to use the app_X.app_X you saw from running ls -l /path/filename before copying the backed up log file.

This is quick comparative review.

Overall for KB1.
TiBu restore of system setting from JS32.2.1 or JS52.2.1 other than WiFi highly discouraged. I had uncurable Force Close for Browser and for MMS. Say g-bye to your messaging history, or find other ways of transferring it.

Original thread is here http://forum.xda-developers.com/showthread.php?t=969343
 

hauj0bb

Senior Member
Nov 8, 2010
267
23
Austin
  • Like
Reactions: loonieryan

loonieryan

Senior Member
Nov 29, 2010
340
76
SMS Backup and Restore is a great app that does exactly what it's title indicates, without root.

https://market.android.com/details?id=com.riteshsahu.SMSBackupRestore

Call logs backup and restore also does exactly what it's title indicates, without root.

https://market.android.com/details?id=com.riteshsahu.CallLogBackupRestore

Both free and developed by the same guy, I've used both many times without a hitch.

I sync my contacts with gmail, so no problem there.

+1

The manual method is pointless and extra work for nothing. These apps work flawlessly. I've used them many times as well.
 

askpcguy

Senior Member
Aug 8, 2010
1,952
189
I know there are apps which backup the same settings, my whole point for posting is I do not backup contacts with Google. So I kept trying different things until putting this together and I know it's a pain but all that really is done is copying and pasting lines into an SU adb shell.
 
  • Like
Reactions: brian213

eyenstien

New member
Feb 2, 2011
2
0
I know there are apps which backup the same settings, my whole point for posting is I do not backup contacts with Google. So I kept trying different things until putting this together and I know it's a pain but all that really is done is copying and pasting lines into an SU adb shell.

You do not use google account or you just don't use it for backing up contacts... :eek:
 

askpcguy

Senior Member
Aug 8, 2010
1,952
189
I use a Google account but not to sync or backup contacts.

Sent from my SAMSUNG-SGH-I897 using XDA App
 

bravomail

Senior Member
Jan 12, 2011
1,003
351
Detroit
Thanks for good info!

Thanks for good info!

I personally don't care about my SMS history. Other people text a lot.

Another alternative is to use Google backup/synchronization. I never tried it. Anyone?
 

rscheller

Member
Aug 9, 2010
12
0
In my experience, backing up phone contacts using Gmail syncing is not 100%. Some fields in the on phone contact records are not properly carried into Gmail contact records and viceversa.

You'd think since Android is Google and Gmail is Google this would work flawlessly.
 

pietro_spina

Senior Member
Jul 20, 2010
178
21
Western MA
I been performing this myself with great success, but you need ROOT access AND busybox installed. Create a folder on your phone's SD card called tmp. You'll need adb in order to adb shell, and gain root access. (in cmd, adb shell <enter> su <enter> confirm you are on a # prompt not the $ prompt)

Now copy and paste each line, press enter after each line pasted. Confirm the files copied after each line by running ls /mnt/sdcard/tmp/mmssms.db
Code:
Next ls -l /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others) to see what permissions/owner they have, if you simply cp the files from /mnt/sdcard/tmp to their locations, you'll get force closes in the application (because it's not able to write log data).

Make note is the owner for each db file.  Then back to adb shell, su, cd /mnt/sdcard/tmp (trust everyone knows to copy the tmp folder from PC onto your phone) cp contacts2.db /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others!).

Once the files are copied back to their locations on the device, run the following:
[CODE]chmod 660 /dbdata/databases/com.android.providers.contacts/contacts2.db
chown app_15.app_15 /dbdata/databases/com.android.providers.contacts/contacts2.db
Obviously you want to use the app_X.app_X you saw from running ls -l /path/filename before copying the backed up log file.

Are you doing all this above because
Code:
cp -p

failed to preserve attributes or something? Or do your fingers like the exercise... :D

Oh, I bet it's because it is that the attributes are getting scrubbed when they are copied off the device to your computer...
 
Last edited:

askpcguy

Senior Member
Aug 8, 2010
1,952
189
I only do this manual method because I want to retain my history and contacts between Roms.

Sent from my SAMSUNG-SGH-I897 using XDA App
 

pietro_spina

Senior Member
Jul 20, 2010
178
21
Western MA
I was asking specifically why you didn't use the "-p" preserve attributes flag when using the cp (copy) command. But I now realize your may be storing your backups in a way that blows away the info anyway. so you need to set ownership and permissions manually after restore..
 

askpcguy

Senior Member
Aug 8, 2010
1,952
189
Because I push the files to an external sd card which is copied to my computer.

Sent from my SAMSUNG-SGH-I897 using XDA App
 

JRd1st

Senior Member
Aug 12, 2010
83
3
TiBu does this, too. But thanks for the info. It's good too know how to do things manually, too.

Sent from my SAMSUNG-SGH-I897 using XDA Premium App
 

askpcguy

Senior Member
Aug 8, 2010
1,952
189
I don't think titanium backup will backup call history. It does get the contacts and calendar though.

Sent from my SAMSUNG-SGH-I897 using XDA App
 

Matt_85

Senior Member
May 24, 2008
106
29
Rome
I found this thread very useful for the restoration of all my recent messages!!:D

the backup i have done with smsbackup&restore is 12hour before the disaster :eek:

what happened? simply after a normal reboot my Desire HD was going to bootloop! i've tried several restore procedures but i find out that /data partition is somehow "bad", don't know why...

the only thing i can do is backup data partition with clockworldmod and unyaff it on a pc;

then i followed the instructions in the OP and i succedeed in making succesfully a backup of all my messages ;

the only difference is the different path in which mmssms.db is located in Desire HD:
i have in /data/data/com.android.providers.telephony/databases/

thank you again mate, very detailed guide :)
 
  • Like
Reactions: askpcguy

askpcguy

Senior Member
Aug 8, 2010
1,952
189
Glad someone found this useful! This is only compatible with Froyo roms, Gingerbread uses the /datadata folder and I haven't needed to manually backup the files because MIUI backup does it so amazingly well!
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,773
8,625
Hampshire, UK
Well, this is pretty neat. I'm forever reflashing my phone and having to reload everything.

Which is a p-a-i-n..

One question though, is there anyway to do all this using "adb shell"? I'd love to incorporate this into a batch file I'm making, with the proper credits of course, and it'd be nice to press a button and have the PC do all the hard work.
 

askpcguy

Senior Member
Aug 8, 2010
1,952
189
Well, this is pretty neat. I'm forever reflashing my phone and having to reload everything.

Which is a p-a-i-n..

One question though, is there anyway to do all this using "adb shell"? I'd love to incorporate this into a batch file I'm making, with the proper credits of course, and it'd be nice to press a button and have the PC do all the hard work.

I tried, I had sort of a working bash script but ran into problems trying to get the script root access to do the copying/restoring. Come to think of it, if you wanted to get fancy, you could make a clockwork mod flashable zip. One for backup and one for restore.

-Yes, I know there are apps which might do this however I wanted to learn on my own.
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,773
8,625
Hampshire, UK
Well, yes, there are backup apps but you have to reinstall those apps and wait while they put your data back in bit by bit. Granted it may not take long but when you're reflashing what seems like once every five minutes, it can take forever!

The zip route seems like a good idea. That way, you can back up, install a rom and restore your details all from one screen. I'll have to have a look at it. :)

Sent from my U20i using XDA App
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    I been performing this myself with great success, but you need ROOT access AND busybox installed. Create a folder on your phone's SD card called tmp. You'll need adb in order to adb shell, and gain root access. (in cmd, adb shell <enter> su <enter> confirm you are on a # prompt not the $ prompt)

    Now copy and paste each line, press enter after each line pasted. Confirm the files copied after each line by running ls /mnt/sdcard/tmp/mmssms.db
    Code:
    cp /dbdata/databases/com.android.providers.contacts/contacts2.db /mnt/sdcard/tmp/contacts2.db
    cp /dbdata/databases/com.android.providers.telephony/mmssms.db /mnt/sdcard/tmp/mmssms.db
    cp /dbdata/databases/com.sec.android.provider.logsprovider/logs.db /mnt/sdcard/tmp/logs.db
    cp /dbdata/databases/com.sec.android.app.memo/Memo.db /mnt/sdcard/tmp/Memo.db
    cp /dbdata/databases/com.android.providers.calendar/calendar.db /mnt/sdcard/tmp/calendar.db
    Once that is done, mount the phone to your computer and copy the TMP folder to your computer. When you flash the custom rom, you'll have to keep the SIM card out of the phone because you do not want new history items written to the log files.

    Next ls -l /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others) to see what permissions/owner they have, if you simply cp the files from /mnt/sdcard/tmp to their locations, you'll get force closes in the application (because it's not able to write log data).

    Make note is the owner for each db file. Then back to adb shell, su, cd /mnt/sdcard/tmp (trust everyone knows to copy the tmp folder from PC onto your phone) cp contacts2.db /dbdata/databases/com.android.providers.contacts/contacts2.db (and the others!).

    Once the files are copied back to their locations on the device, run the following:
    Code:
    chmod 660 /dbdata/databases/com.android.providers.contacts/contacts2.db
    chown app_15.app_15 /dbdata/databases/com.android.providers.contacts/contacts2.db
    Obviously you want to use the app_X.app_X you saw from running ls -l /path/filename before copying the backed up log file.

    This is quick comparative review.

    Overall for KB1.
    TiBu restore of system setting from JS32.2.1 or JS52.2.1 other than WiFi highly discouraged. I had uncurable Force Close for Browser and for MMS. Say g-bye to your messaging history, or find other ways of transferring it.

    Original thread is here http://forum.xda-developers.com/showthread.php?t=969343
    2
    That's great! Now make a backup.

    Sent from my SAMSUNG-SGH-I727 using xda premium
    1
    SMS Backup and Restore is a great app that does exactly what it's title indicates, without root.

    https://market.android.com/details?id=com.riteshsahu.SMSBackupRestore

    Call logs backup and restore also does exactly what it's title indicates, without root.

    https://market.android.com/details?id=com.riteshsahu.CallLogBackupRestore

    Both free and developed by the same guy, I've used both many times without a hitch.

    I sync my contacts with gmail, so no problem there.
    1
    I know there are apps which backup the same settings, my whole point for posting is I do not backup contacts with Google. So I kept trying different things until putting this together and I know it's a pain but all that really is done is copying and pasting lines into an SU adb shell.
    1
    I found this thread very useful for the restoration of all my recent messages!!:D

    the backup i have done with smsbackup&restore is 12hour before the disaster :eek:

    what happened? simply after a normal reboot my Desire HD was going to bootloop! i've tried several restore procedures but i find out that /data partition is somehow "bad", don't know why...

    the only thing i can do is backup data partition with clockworldmod and unyaff it on a pc;

    then i followed the instructions in the OP and i succedeed in making succesfully a backup of all my messages ;

    the only difference is the different path in which mmssms.db is located in Desire HD:
    i have in /data/data/com.android.providers.telephony/databases/

    thank you again mate, very detailed guide :)