Tuesday, December 27, 2011

Recover text messages from nandroid backup

The objective is to restore the text messages that were on my Android phone before it got re-flashed, with an end result of all the old and current text messages being on the phone.

I have a nandroid backup image at ~/work/backup/, and the phone attached by USB with debugging enabled.

Previously I tried to install the yaffs file system on a Linux box and mount the image over loop back, however that did not work, the images failed to mount.

The solution turns out to be simple...

download the source for unyaffs, a program which extracts all the files form a yaffs image.

download unyaffs.c and unyaffs.h into ~/work/.

compile the source.
cd ~/work
gcc -o unyaffs unyaffs.c

make a target directory and run the program from the target directory.
mkdir data.img
cd data.img
../unyaffs ~/work/backup/data.img

after some quick reading I find that the text message database are at data/com.android.providers.telephony/databases/mmssms.db.

On the phone use SMS Backup & Restore to save the current text messages.

Make a backup of the message database on the phone, just in case.
adb pull /data/data/com.android.providers.telephony/databases/mmssms.db ~/work/mmssms.db-current

Push the pre-flash message database with the old messages onto the phone
adb push ~/work/data.img/data/com.android.providers.telephony/databases/mmssms.db /data/data/com.android.providers.telephony/databases/mmssms.db

Reboot the phone.

Only the old messages should be visible on the phone now.

On the phone use SMS Backup & Restore to restore the text messages that were just saved, there should be no need to check for duplicate messages.

All the messages should be visible now. All done.

1 comment:

  1. Do you use SMS alerts in your business? To notify my customers about new income of products, I do that through https://www.intistele.com/sms-api/ sms gateway provider. To be polite and punctual, I use the templates. What I may to say, it is easy to comunicate with client, through the messages.

    ReplyDelete