Jump to content

Backup Messages the ADB Way


Recommended Posts

Guest Dr. dre
Posted (edited)

Can anybody give me the command to backup messages through the ADB way, I have manged to get my contacts backed up but i can't find a way to for the messages.

I gave this command for the contacts

adb pull /data/data/com.android.providers.contacts/databases

Edited by Dr. dre
Posted

iirc it is /data/data/com.android.providers.telephony/databases/mmssms.db

Guest Dr. dre
Posted (edited)

and what's for call log ?

Edited by Dr. dre
Posted (edited)
Kendon help!

sry, no idea. tbh i don't see the call log as important enough to save it... nevertheless if iyou find the answer please post it here.

edit: damn am i good :D

/data/data/com.android.providers.contacts/databases/contacts.db

just extracted it from a nandroid backup and pushed it, works fine.

Edited by kendon
Guest Dr. dre
Posted (edited)
/data/data/com.android.providers.contacts/databases/contacts.db

just extracted it from a nandroid backup and pushed it, works fine.

Dude I have pulled this file already but haven't tried pushing it back, so does this restores the call log or just the contacts ?

Edited by Dr. dre
Posted
Thanks for the help dude. Your the best!!!

glad i could help :D

Guest knudsen81
Posted
glad i could help :D

when i use adb to pull out msg file can i so push it back in any rom????

thanks for you help

Posted
when i use adb to pull out msg file can i so push it back in any rom????

thanks for you help

i would think that it works with ever "major" version, ie if you pulled it from a 2.73.x.x rom then you can push it back to any of these. for 2.1 i have no idea, just try it?

Guest Trebor Rude
Posted
sry, no idea. tbh i don't see the call log as important enough to save it... nevertheless if iyou find the answer please post it here.

edit: damn am i good :D

/data/data/com.android.providers.contacts/databases/contacts.db

just extracted it from a nandroid backup and pushed it, works fine.

I tried this method (push contacts.db) on my Tmobile pulse, and it didn't work. It deletes all the contacts when I reboot the phone (the .db file size actually changes, and all entries disappear from the 'people' table when I look with sqlite3). Of course, this being a Hero board, I don't know if anyone will be interested in that. :D

Guest Dr. dre
Posted
I tried this method (push contacts.db) on my Tmobile pulse, and it didn't work. It deletes all the contacts when I reboot the phone (the .db file size actually changes, and all entries disappear from the 'people' table when I look with sqlite3). Of course, this being a Hero board, I don't know if anyone will be interested in that. :D

This is a method which is tried and tested on a Hero device, so I don't think this would work on a pulse.

Posted

I'm not sure why this thread morphed into backing/restoring contacts, but the original subject was for backing up messages right ?

It's actually really easy to do and even to move it from one phone to another. You should never copy the db direct (unless moving onto the same phone/db version), but instead take a sql dump of your data and after ensuring the table columns are in the same order/type, just reimport it into the new db structure.

Moral of this is always keep your /data/data/* files backedup.

Here is a sample (the sqlite3 command exists for linux/windows/mac):

laptop$ sqlite3 data/com.android.providers.telephony/databases/mmssms.db

SQLite version 3.6.16

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> .tables

addr				 incoming_msg		 raw				

android_metadata	 part				 sms				

attachments		  pdu				  sr_pending		 

canonical_addresses  pending_msgs		 threads			

cbch				 qtext			  

drm				  rate			   

sqlite> .headers on

sqlite> select * from sms;

_id|thread_id|toa|address|person|date|protocol|read|status|type|reply_path_prese

t|subject|body|sc_toa|report_date|service_center|index_on_sim

1|1|0|+xxxxx||1259033347278||1|-1|2|||Sample SMS|0|||

..etc...
So this command will dump it out for you in text,
laptop$ sqlite3 data/com.android.providers.telephony/databases/mmssms.db 'select * from sms' >sms.txt

then you can just reimport it into your new db. Remember to put your phone in airplane mode, or do it from the recovery console so to consumers are not updating the db at the same time. I'm sure you don't wanna loose messages.

It's trivial to write a script to backup and restore contacts,sms,APN's, etc..

Posted
So this command will dump it out for you in text,

laptop$ sqlite3 data/com.android.providers.telephony/databases/mmssms.db 'select * from sms' >sms.txt

then you can just reimport it into your new db. Remember to put your phone in airplane mode, or do it from the recovery console so to consumers are not updating the db at the same time. I'm sure you don't wanna loose messages.

It's trivial to write a script to backup and restore contacts,sms,APN's, etc..

this is interesting, could you give us the command to restore aswell? i am not familiar with sql.

the problem here is that many people struggle already to use simple file operations with adb, let alone manipulating the contents of the database... most are capable of copying a file from the phone to their pc and back, but altering databases in between...

nevertheless, good argument! :D

Posted (edited)
this is interesting, could you give us the command to restore aswell? i am not familiar with sql.

the problem here is that many people struggle already to use simple file operations with adb, let alone manipulating the contents of the database... most are capable of copying a file from the phone to their pc and back, but altering databases in between...

nevertheless, good argument! :D

As mentioned as long as you ensure the columns are in the same order (i.e. the db schema is the same) you should be fine with the following

You should first look at the SMS schema with the command

.schema sms
then first dump the db as i showed previously to a txt file (the sms.txt file in this example)
sqlite3 data/com.android.providers.telephony/databases/mmssms.db 'select * from sms' >sms.txt
then reload that file into a new db (i.e. a clean phone with no entries or else you will end up with dup entries) with
sqlite3 data/com.android.providers.telephony/databases/mmssms.db '.import sms.txt sms'

Then push that mmssms.db file to your fone.

If someone wants to dump me the schema from a 2.x ROM for the SMS/MMS db i will write you a script from convert from 1.x to 2.x db. It is extremely simple with a few sql commands. As long as you have a backup of the db file you can always revert (i..e push the original via adb to your fone) if it doesn't work.

Edited by daveba
Guest Trebor Rude
Posted
This is a method which is tried and tested on a Hero device, so I don't think this would work on a pulse.

It did end up working, I just had to force the contacts application to close after installing the db. I suspect the contacts service had something to do with it.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.