Prelude
This is an addition to an article about restoring your contacts. The tutorial can be done on Windows, Mac or Linux and is totally free. In the end you will get an xml file, that you can put back on your phone.
My program got downloaded over 30.000 times and I got a lot of great responses, so chances this solution works for you, are rather high!
Restore data in 18 easy steps
For this solution you need to install Java (RE)! Time estimation for the tutorial: 15 minutes
The program works on Windows, Mac and Linux, with this 12 step guide you will be able to restore your messages, but you could use it for any other files as well.
- Download my program: Download.
- Extract the folder “restoreSMS” in there to your desktop (Just drag and drop it).
- Navigate to the folder your backup is saved to. By default your backup is saved to C:\Users\YourUserName\Documents\Sony\Sony PC Companion\Phone Backups
- You should find the backups with the file extension “.dbk”. Create a copy of your backup (ctrl+c, ctrl+v) just in case something goes wrong.
- The dbk extension is actually just a zip file, so you can just rename the file. If you see the .dbk extension in the file name you can skip this the step. Otherwise you have to disable a windows explorer feature. For that click in your opened window on organize -> Folder and search options and there switch to the tab View and disable the feature Hide extensions for known file types.
If you having this problem with an other version of windows just google “windows yourVersion show file extensions”.
- Rename your file copy to backup.zip (F2)
- Open your file (double click). If you have no program to open zips I highly recommend 7zip.
- Now you have to navigate to your message file. You will find it here
Applications\com.android.providers.telephony\fullbackupdata
If none of these folders exist the backup won’t have the sms-data included. - Copy the fullbackupdata file to the folder on your desktop from step 2. Put it in the folder “restoreSMS\1” (Just drag&drop it there).
- If you’re on windows, double click “RunInWindowsConsole.bat”, otherwise double click on “restoreData.jar” in the folder “restoreSMS\1”. Within a few seconds a file with the name “restore.tar” should show up. If it doesn’t make sure that you have java installed and the fullbackupdata file is in the folder.
- Open the file with 7zip or a similar program.
- Now navigate through the folders to
apps\com.android.providers.telephony\db\mmssms.db
This file holds the messages you are looking for. Sadly you can’t import it that way. First we need to parse it to get an XML file. - Copy the mmssms.db file to the other folder (“restoreSMS\2”).
- Now double click “RunInWindowsConsole.bat” on windows, otherwise double click “RestoreSmsToXML.jar” in “restoreSMS\2”.
- If everything worked out the right way, you should get a file called “extractedSMS.xml”. This is the file you can put back on your phone. Therefore connect your phone with the pc and upload the file to your phone.
- To get the messages back to your message app you need to download another app called SMS Backup & Restore. I have no connection with the person who created that application, but it is for free and serves our purpose.
- In the app you just have to click restore and search for the xml file you put on your phone.
- That’s it, you should have your messages back on your phone!
For all interested, the program is a fork of Android Backup Extractor by Nikolay Elenkov. He actually did almost all work, I just added a few changes to make the program easier to use (for this particular problem). Most of the SMS restore work came from Huỳnh Giang Sơn. thank you for your work, otherwise I wouldn’t have had the drive to put up this article here.
I hope this program helped you. If so, I would be happy if you leave a comment or show your appreciation by click the paypal button. I’m also happy to hear from you, if you hadn’t had problems!
If you want to restore your contacts, take a look at this article.
Would it matter if the messages were from an Xperia Z (C6606) and were then restored on an Xperia Z1S (C6916)?
Hello Ale,
Not at all, the file format xml (And the app I’m linking to) works for all android devices, it is an open standard 🙂
Awesom work!, thank You soo much Johannes!
I have tried and tried but no success until I got hold of this!
My old phone got wierd after upgrade so I just could get the Sony dbk-file out…and this guide helped me to suceed!
Greetings from Sweden
You’re most certainly welcome, happy to hear that you were able to restore your messages!
almost 5600 sms from years back was restored 😉
(yes Im a keeper)
Greatful U took the time to share youre knowledge!
Success! Thanks thanks thanks Johannes, I’m now trying to figure out how to restore my Notes since the newest Companion (ex pc-companion) failed miserably to restore all my backup made under Lollipop to my downgraded KitKat.
I have finally restored old messages from my sony experia zr to samsung s7!!! I have searched for days for a solution to my problem from sony’s app to samsung’s app and downloaded so many useless restore apps. Thank you so much!!! Your tutorial worked! I am so grateful 🙂
Awesome to hear that I was able to help you, thanks for the feedback and sorry that you had to click through so much crap before, I had the same problem before I developed this small application.
Thanks, Johannes. My Sony Xperia Z3 crashed so had to buy a new phone (HTC M10). So grateful for this program. Helped me restore thousands of messages.
Awesome, I’m happy I was able to help, thanks for the comment!
Hi,
After restoring my contacts thanks to you i restored my sms !
But i only get received message, is this method suppose to restore send and received message ?
PS: Have you a magic thing to also restore notes ?
Thanks !
I get back my 8000 messages :D, is was just a bit long that’s why i did not see my send messages, thanks a lot for you hard work !
Any solution for notes ? i’ve got a long list and it would we great if you know how to get it ?
I open the fullbackup file of notes and i got these files :
notes.db
notes.db-journal
google_analytics_v2.db
Can i do something with this ?
Man, Thanks a lot
You’re welcome 🙂
Thank You very much for this tutorials: address book restore and SMS restore.
Informations was very useful.
You are great
Always happy to help, thanks for the comment
Hi Johannes,
I tried to use your program, but the Xperia companion encrypted the backup file (I have the password, but due to rolling back android on my phone, I cant use companion to restore SMS any longer) When I run your program using the java command line, I get a runtime exception:
Exception in thread “main” java.lang.RuntimeException: java.lang.IllegalArgumentException: Backup encrypted but password not specified
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:196)
at org.nick.abe.Main.main(Main.java:38)
Caused by: java.lang.IllegalArgumentException: Backup encrypted but password not specified
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:86)
… 1 more
Can you help me figure out where to go from here?
Cheers!
Sri
Hi Sri,
I have bad news for you. The encryption for backups via Sony PC Companion was added long after I created this small tool. There is a possibility to use the program for backups encrypted via android itself, but not with Sony PC Companion. It is using an other encryption procedure and I don’t know which one. If you can figure that out, I might be able to add the decryption to this little application as well.
Greetings from Germany,
Johannes
I have a problem with encryption as well. Backup created with Xperia companion as well. Difference is there is no .dbk file (afaict), but the files from the phone are stored separately in Xperia companion subdir called “backup”. I have the “fullbackupdata” file from “socialphonebook”, but can’t get it decrypted with Johannes’s tool or abe. Abe gives me this error:
Caused by: java.lang.RuntimeException: javax.crypto.BadPaddingException: Given final block not properly padded
When i open the file in text editor i see this at the top:
ANDROID BACKUP
3
0
AES-256
Some googling revealed this:
“The first line is the file ‘magic’, the second the format version (currently 1), the third is a compression flag, and the last one the encryption algorithm (‘none’ or ‘AES-256’).”
https://nelenkov.blogspot.de/2012/06/unpacking-android-backups.html
Johannes can you make any sense of this? Is the problem maybe that third flag (compression) is set to 0?
Thanks for all your great work.
Hi Michael,
You did your job rather well! Sadly the information at the top is the same as with an encrypted file from android, so there is no difference there. I guess that sony is using some kind of salt or a slight variation in their AES256 implementation which is different to the android one. That’s why you get the error, it is just not matching the encryption and therefore read the wrong way. I haven’t figured out a solution to this problem / I have no idea what sony does with their encryption.
Greetings from Germany,
Johannes
Good day, I want to say Thank you for your help and of corse of your program, but I have a little problem. I had create pdk file, and change his extension, and do all steps, BUT, when I trying to launch restoreData.jar nothing happend, but when I’m trying to open it with java (java -jar restoreData.jar) I get a mistake like this:
D:\>java -jar restoreData.jar
Magic: ANDROID BACKUP
Version: 3
Exception in thread “main” java.lang.RuntimeException: java.lang.IllegalArgument
Exception: Don’t know how to process version 3
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:180)
at org.nick.abe.Main.main(Main.java:35)
Caused by: java.lang.IllegalArgumentException: Don’t know how to process version
3
at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:64)
… 1 more
D:\>
and I really didn’t know what to do. Help me please
Hello Arstan,
Seems like you have downloaded an old version of my program. Please try to download it again from my website. Here is the link: https://deml.io/data/out/restoreData.zip
Greetings from Germany,
Johannes
Hi Johannes,
My problem is that I created a backup on my sdcard. So there is no “full backup” per say and that is why your application is crashing for me 🙁
The backup I created on the sdcard has individual files for contacts such as “CONTACTS” and “CONTACTS_meta” and a few more.
I would really appreciate your help!
Cheers,
Omer
Hi Omer,
I didn’t even know that that was possible with Sony PC Companion… or did you use an other program /app?
I can’t really tell what is going on, because nobody with that problem came to me. If you want to, you can send me one of those contact files and I’ll take a look if I can make any sense from it.
Greetings from Germany,
Johannes
Hi Joannes,
Cheers for the quick reply. I’m sorry if I wasn’t explicit in my earlier message. Those files were created by the phone itself when I chose to “Backup” using the native Sony Backup and Restore app onto the sdcard.
Sure I can send it across, may I know your email address?
Cheers,
Omer
Sure, it is public@deml.io 🙂
Any luck brother?
Hey there,
I did some research. The files are encoded totally different than from the normal backup process. There is another person with the problem you have over there: https://talk.sonymobile.com/t5/Xperia-Z5-Z5-Compact-Z5-Premium/Decode-SonyBnR-Backup-amp-Restore-files/td-p/1167069
I took a quick look if there is any program that can easily decode the files, but sadly the XT standard is not that popular and you would also need the information of how the xml is structured (an xsl file) in order to decode it.
Sadly I won’t have the time to help you out on this one (especially because the result if it will work is rather uncertain). Maybe you will do a better research than me or maybe you have your files synced somewhere else? (e.g. Google: http://contacts.google.com/)?
All the best,
Johannes
Hi Johannes,
Very useful article, thank you!
My old Xperia M died two days ago. With the help of your program I could restore my SMS messages from the last .dbk backup file to a new Huawei phone.
Is there a way to restore the MMS messages with pictures as well?
As I understood from the .dbk structure the pictures are also stored in the backup file so theoretically it is possible I think.
Thank you again
Peter
Hey there peter,
Thanks for the comment, I’m happy you got it working right away. As for the pictures: Well, there are included in the backup if you checked it when doing the backup. My guess is, that the pictures will be stored a .jpg files somewhere without the direct context of the messages themselves. That should make it easier to retrieve them. I can’t tell you where to find them, but I would suggest to sort the folders in the dbk file (which you converted to a zip) by their size. You can easily do that with 7zip. Take a look at the folders that are larger than 10 mb.
If there are no fullbackupdata files but just some strange names there try to add the file extension .jpg and see if you can open the file as a picture. I remember one case in which that technique worked for audio files, maybe it can work you too. The files do not have to be jpgs, but some could be. That would be my way of solving the problem. Not that elegant, bu it might just work 😉
All the best and happy holidays,
Johannes
Thank you very much. With help of your app I recoverd my daughter Exploration worlds she has been building since many months! Thanks I manage to make a backup previously.
I will donate you tomorrow.
I’m really happy to hear that, especially if my little program was able to save something precious to your daugther!
Greetings from Germany,
Johannes
Hi Johannes. Do you if and how can I merge 2 backups? I have a very old backup that has parts of conversations and the current database in my phone which is missing those conversations. I want to merge everything together.
Any idea about how to do this?
Thanks!
Hi Victor,
So it is about sms conversations? Hm, well couldn’t you just follow the tutorial with both backups and merge the data by importing both files with the sms backup and restore app? Or does that app override already existing messages?
Hi Johannes,
I am eager to extract my messages from a Sony Companion backup file. The device from which I made a backup is no longer working.
I could not locate the *.dbk file. Nonetheless, I could find under C:\Users\SaiRam\Documents\Sony\Xperia Companion\Backups\4eb337a43ffb2363de915aa9be0316df8342eb1f\f8bb6cada032e9fd29c23aa18741b3694b2db9b9\com.sonyericsson.conversations a file called fullbackupdata. I renamed this file as .zip (I am not sure, if my approach is right). However, upon double clicking restore.jar, nothing happened. I have Java in my system. I use Windows 10. I tried opening fullbackupdata.zip. It’s password protected. I used the password through which I created the backup file. Doesn’t work.
I will be grateful if you can advise.
Thanks and Regards.
Hi Shekhar,
You have just a different file structure (even though I don’t know why some people have a file structure like you have, and most other have the one I was describing). In your case, you don’t have to rename anything. Just take the fullbackupdata (the one you renamed to fullbackupdata.zip) and run my program on that file. In the tutorial start at step 7 🙂
Greetings from Germany
Johannes
Hi Johannes,
great work and I appreciate it!
sms and contacts extractor worked very well.
One question regarding the calendar items, I think that RestoreSmsToXML.jar can be used too, just xsl file should be update according to calendar file structure.
Is that right?
Thanks,
Tomas
Hi Thomas,
Happy to hear that I was able to help 🙂
As for the calendar: Not quite sure how the file structure of the calendar is, and if it is really xml how to get the xsl file. If you find a .db file you can use something like sqlitebrowser to take a look at the data. If you find a solution please let me know 🙂
Dear Johannes,
I would so much like to restore my old sms from my backup file as per your instructions!! Actually I am stuck at your step no. 14 when you declare “Now double click the program “RestoreSmsToXML.jar” in the same folder.
If everything worked out the right way, you should get a file called “extractedSMS.xml”. I have double clicked on my RestoreSmsToXML.jar file but nothing happens!!! Can you help? Thanks a lot in advance.
Hey there Nadia,
I noticed that I’m not using the current version of my program in the downloads. I also added another batch file to easily run the program in the console. Please download the zip again and follow the steps. If anything does not work, you will get information about the problem in the commandline. This way I can identify the problem more easily.
Greetings from Germany
Johannes
Than you for this solution! it saves me !
Awesome, really happy to hear that the program is still helping people 🙂
Dear Sir
I write these lines because I am really stuck (and puzzled as well) in a process of data restoration from an Xperia Companion backup concerning three items only, namely contacts, settings and messages.
I did manage to restore the contacts and settings but I run into difficulties in relation to the message restoration. The problem is that I can recover a part of the messages only (about 60%).
When I found your post I was really happy but just for a bit because I noticed that no file having the (.dbk) extension had been created in the Sony’s Backups folder.
I was wondering whether there is any chance to restore the messages given the lack of the (.dbk) file.
Thank you.
Regards,
Giani
Hello Giani,
I think over the years their backup structure changed, so you might find it in another place. What I’ve seen lately is a folder named in hexadicmal (something like 3289d45ae7c9). In there you would find the folder or file com.android.providers.telephony. If it is saved as a file, just copy and rename it to fullbackupdata. Then start the tutorial from step 6 with skipping step 8.
If you’ve got problems you could also send me a mail.
Greetings from Germany
Johannes
Hello Johannes,
I have read your instructions but still cannot restore my SMS messages from my Xperia Z5. My situation was: My Sony Xperia Z5 was stolen in 2016 but I had made a backup on my PC with Sony Companion before that. Once I bought my new Samsung S8, I wanted to put the backup messages into it again but failed until now. In the backup folder, there is no .dbk file but .xml instead, so I thought I would skip your guide to step 15. However, when I opened the messages.xml with SMS Backup & Restore app, it said the file was invalid 🙁 . Hope you can help me again! Thank you very much!
Hi Sam,
Hm, hard to tell. It is very important to have the correct structure of the xml file. If you want to I can take a look at you file. Just send it to public@deml.io. Sadly I can’t promise anything, but I will take a look 🙂
Hi Johannes, do you have any updates on this ?
I’m facing the same problem: a sony companion backup and a new non-sony phone. The text messages are in a file “message.xml” and comparing it with a test backup I made with the non-sony phone, I found out that the keywords used in the XMLs were different.
I managed to tweak it a bit to have the proper format but… I only tested it on a few messages and lost a bit of information. It’s quite tedious, uncertain (I’ve never used XML files before) and the sony xml has plenty of keywords “sms, “thread”, “mms”, “mmspart” whereas the others just have “sms”. I’m quite unsure on how to adapt them, should I just label them as sms ?
I’ve figured out how to adapt a few obvious ones like the address, date, type but not all of them.
I wondered if you had any tips about this ?
And good job !
You’ve made an amazing work and your devotion is really impressive (offering to send you mails, all those detailed answers and case-studies, …), you’ve helped loads of people and that’s awesome.
Thank you a lot for being so nice !
Hello Maxime,
sorry for the late response, you comment somehow slipped under my radar. First of all thanks for your nice comment, it always makes me happy to read, that somebody somehow randomly bumped into my site and finds something useful for them!
As for your problem: Sadly I don’t have a one button click solution for you. I would probably go the same route as you, and just do a find and replace thing. If you want to find and replace in multiple files, I recommend using Visual Studio Code and then opening the underlying folder. You could also do a regex search. For that I would recommend using https://regex101.com/ with a small excerpt of your xml file to get your regex string the way you want it to, and then using the IDE of your choice to apply that regex.
Sadly I don’t have that much knowledge of the XML structure as to tell you, if you would break anything when replacing everything with sms, I guess you have to do a trial and error approach.
Good luck and greetings from Hamburg (btw. Lyon is beautiful!)
Johannes