FORUMS
Remove All Ads from XDA

WhatsApp - restore encrypted backup (crypt12) (full backup of phone required)

32 posts
Thanks Meter: 14
 
By sexler, Member on 15th September 2016, 03:09 PM
Post Reply Email Thread
What’s this about?
WhatsApp was driving me nuts the other day! Why? Because it would not restore my message backup without a reason.

When I take the time and read the following will it help me?
Well, maybe. That depends on what you did. I wanted to restore my WhatsApp encrypted backup file (FILE! not Google backup) and it worked out.

When will the following maybe help me?
  • you have a WhatsApp backup file (encrypted, e.g. crypt12 -> msgstore.db.crypt12)
  • you wiped your phone’s data
  • you have a backup of your phone (TWRP or similar) or already have the WhatsApp key

What happened to you?
I changed from stock ROM to custom ROM (CyanogeMod in my case). Because I did a clean flash I made some preparations in advance. I backed up my WhatsApp messages and copied the whole folder to my SD card. I wiped my phone using TWRP (system, data, cache...). After the custom ROM flash I installed WhatsApp and wanted to restore my messages. Didn’t worked out.

What happened?
I did a little bit of research and little did I know the message file was encrypted. Because WhatsApp is super smart it stores the key for the decryption not in the WhatsApp folder (okay, this would really be stupid). As soon as you wipe your data the key will be erased. Good bye key! So, I am not an expert and it could be that there is a way easier method to restore you messages but I didn’t found one. I just want to share my experience so hopefully someone can save a lot of time. I would have been happy if I found something like this earlier or if I would have at least known about the key. Now I know.

NOTE
Without a backup of your phone, to be more specific, of your phone’s data or the WhatsApp key the following will be useless!

NOTE
Your phone can get broken! I am not responsible for that. Everything you do is on your own risk! Also, I’ll try to help but I am not a 24/7 support technician.

NOTE
Read everything first before you start! Maybe I messed something up. So, take a look first!


So, what to do?

1) Retrieve the key from your phone’s data backup.

a) Because we are all smart we do a full backup before we flash crazy stuff on our phone, right?! I did that with TWRP. Any other backup might work as well. You’ll have to find out on your own. The TWRP backup file is something like “data.ext3.win000”, “data.ext3.win001”. Copy it to your computer. Add the extension .tar or .tar.gz (“data.ext3.win000.tar”, “data.ext3.win001.tar”). In my case both worked. If you can already browse your backup file continue with e).

b) Download and Install 7-Zip.

c) With the 7-Zip file manager you can open and search inside the renamed TWRP files.

d) 7-Zip doesn’t recognize if your data is stored in more than one file. I guess if you pick the right file extensions it would. But, like I said, I am not an expert. So, in this case the win000-file has other files in it than the win001-file. If you don’t find the key in the first one, open up the next one.

e) Open the first file. There will be some kind of blank folder. Open it and you’ll see your phones data. Navigate to \data\data\com.whatsapp\files\.

f) There you should see a file named key. If so, start yell “hurray!”. In my case I saw two key files. I don’t know why but every file was doubled (maybe someone can explain that to me).

g) One of the files was about 158 Bytes. That should be it. To be sure extract the first key file. Open it with the windows editor. If there are letters in it that you can read it’s the wrong file.

h) Extract the other one and open it, too. You see some gibberish? Congratulations, this should be your key! Copy the file to your phones SD card or something similar.


2) Restore your backup

a) Install WhatsApp if not already happened. If you already activated the app go to settings, apps, select WhatsApp and erase all data (NOTE! Your own risk! All data will be gone!). This is necessary because WhatsApp will only ask once after the activation if the backup should be restored. Maybe there is another way but I don’t know it.

b) Copy the whole WhatsApp folder to your phone (the backed up one from the SD, see above). Or just put the backup file into \WhatsApp\Databases\. If you have an older backup file like msgstore.db-2016-01-01.crypt12 rename it into msgstore.db.crypt12. As far as I know only the last named file will be restored.

c) Start WhatsApp and activate it.

d) STOP! WhatsApp will ask you if it should restore the backup. Don’t do it! If you did it and it failed start again from a). Just leave the screen like that, don’t do anything. Turn off your phone! Yep, you heard right. WhatsApp will remember the state it’s in.

e) Boot into TWRP. If you have a file manager that can access your phones data you could use that one, too. I think root will be required for that. I just had the limited stock file manager. The latest TWRP has a file manager integrated without restrictions (check for yourself first!). I used that one (complicated maybe, I know!).

f) Open the file manager (Advanced - File Manager) and navigate to your key-file. Tap on it and select copy.

g) Navigate to \data\data\com.whatsapp\files and copy the key-file into this folder (just tap the blue folder at the right bottom of the screen).

h) Reboot you phone. Start WhatsApp. It should open up and directly ask you if you want to restore your backup. Try to restore it. If you’re lucky it’ll work. For me it did! Congratulations.


Endnote
  • I didn’t know about the key when I erased my phone’s data. Next time that one will be backed up, too. So I can save a lot of time.
  • This whole thing here might be very complicated and I guess there is a lot better way to do it. But I didn’t found it. So, I just want to at least share my experience. Maybe someone will profit.
The Following 3 Users Say Thank You to sexler For This Useful Post: [ View ] Gift sexler Ad-Free
11th October 2016, 01:33 PM |#2  
jult's Avatar
Senior Member
Flag Amsterdam, NL, EU
Thanks Meter: 120
 
More
Another thing you need to know here;

The file named key should have a UID WhatsApp for user and group permissions.
You can set these using TotalCommander via Properties
and you should set these while whatsapp is killed/down and while the key is already in the /data/data/../files/ dir.

I also had a case where in the last stage, so before the final boot to restore the database, I had to do a Wipe Cache and Dalvik cache. If I did not do that, whatsapp would skip the restore question and continue activation as if it was a new one, and then *overwrite* the key file I had put there, no matter what I tried!
The Following User Says Thank You to jult For This Useful Post: [ View ] Gift jult Ad-Free
12th October 2016, 12:46 AM |#3  
Senior Member
Thanks Meter: 153
 
More
You don't have to do any of this if you haven't changed your cell number!

1) Copy your latest crypt 12 file to /sdcard/WhatsApp/Databases/
2) Install / Activate WhatsApp
3) WhatsApp will retrieve the key from their server and restore your backup.

This only works if you haven't changed numbers, but it's easy as 1, 2, 3!
12th October 2016, 08:18 PM |#4  
OP Member
Thanks Meter: 14
 
More
I tried this but it didn't work out for me. Thats the reason I wrote this. So far couldn't find another way to restore the backup. Maybe in newer WhatsApp versions this works?!
12th October 2016, 10:48 PM |#5  
jult's Avatar
Senior Member
Flag Amsterdam, NL, EU
Thanks Meter: 120
 
More
Quote:
Originally Posted by TripCode

You don't have to do any of this if you haven't changed your cell number!

1) Copy your latest crypt 12 file to /sdcard/WhatsApp/Databases/
2) Install / Activate WhatsApp
3) WhatsApp will retrieve the key from their server and restore your backup.

This only works if you haven't changed numbers, but it's easy as 1, 2, 3!

That's actually not true. I followed their instructions to the letter, but they failed. I did not get a Restore prompt, and it actually erased the entire whatsapp cryptxx file.

The official way probably fails when you upgrade from LL to MM, but I'm not so sure about even that, because it also failed a long time ago on my htc desire just changing from rom to rom (with a clean /data/data dir).
13th October 2016, 10:37 AM |#6  
Senior Member
Thanks Meter: 153
 
More
Quote:
Originally Posted by jult

That's actually not true. I followed their instructions to the letter, but they failed. I did not get a Restore prompt, and it actually erased the entire whatsapp cryptxx file.

The official way probably fails when you upgrade from LL to MM, but I'm not so sure about even that, because it also failed a long time ago on my htc desire just changing from rom to rom (with a clean /data/data dir).

Sounds like you have had a bad experience. I do a lot of dev work with WhatsApp. I have swapped between several devices as low as API7 to API24. I have never had an issue restoring WhatsApp via the official 3 step method. My devices use a selection of stock / custom roms. As long as you got it working that's the main thing, but I would advise people to try the official restoration procedure before they venture into anything more technical as the official procedure will work most of the time.
4th April 2018, 07:25 PM |#7  
Junior Member
Thanks Meter: 0
 
More
Hi, I googled and came to this page.

I hope someone can help in restoring either local .crypt12 backup file or from google drive backup.

It started when my phone got no space and WhatsApp crashed.

For the first time, I clicked restore but it couldn't restore as got no space and WhatsApp closed the app itself.

I was carelessly when starting WhatsApp again and didn't click "restore from previous database" on the 2nd time.

I searched online for the WhatsApp help and deleted some apps to free up space.

Then, I uninstalled WhatsApp and reinstalled again. However, the problem came when after re-installation and needed to authenticate my old WhatsApp number by SMS.

As I just kept using the old WhatsApp number that was originally from a prepaid SIM card which I bought years ago and I didn't top up the stored value for a few years back, so I couldn't receive voice and SMS from that old WhatsApp number as it was properly become a dormant mobile number .

Is that a way I can restore from, for I made a copy of the crypt12 database before uninstalling WhatsApp (I didn't copy the key before uninstalling & reinstalling, and I am not sure if I had a copy of the key before, that I tried to backup using windows explorer to copy to my computer long ago.

Many thanks.

Quote:
Originally Posted by TripCode

Sounds like you have had a bad experience. I do a lot of dev work with WhatsApp. I have swapped between several devices as low as API7 to API24. I have never had an issue restoring WhatsApp via the official 3 step method. My devices use a selection of stock / custom roms. As long as you got it working that's the main thing, but I would advise people to try the official restoration procedure before they venture into anything more technical as the official procedure will work most of the time.

27th May 2018, 01:22 PM |#8  
Member
Thanks Meter: 0
 
More
hi i used yowhatsapp and try to use the original whatsapp app i get messages back but cant see old pictures and cant here old voice messages they were imported somehow to the new package named com.yowhatsapp istead.

could someone point me in the right direction on how i can restore whatsapp with mediafiles`? my mediafiles are all there but just working with yowhatsapp
28th September 2018, 06:37 PM |#9  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by lycca

Hi, I googled and came to this page.

I hope someone can help in restoring either local .crypt12 backup file or from google drive backup.

It started when my phone got no space and WhatsApp crashed.

For the first time, I clicked restore but it couldn't restore as got no space and WhatsApp closed the app itself.

I was carelessly when starting WhatsApp again and didn't click "restore from previous database" on the 2nd time.

I searched online for the WhatsApp help and deleted some apps to free up space.

Then, I uninstalled WhatsApp and reinstalled again. However, the problem came when after re-installation and needed to authenticate my old WhatsApp number by SMS.

As I just kept using the old WhatsApp number that was originally from a prepaid SIM card which I bought years ago and I didn't top up the stored value for a few years back, so I couldn't receive voice and SMS from that old WhatsApp number as it was properly become a dormant mobile number .

Is that a way I can restore from, for I made a copy of the crypt12 database before uninstalling WhatsApp (I didn't copy the key before uninstalling & reinstalling, and I am not sure if I had a copy of the key before, that I tried to backup using windows explorer to copy to my computer long ago.

Many thanks.

Did this yesterday but this will only work if your number has not changed, first uninstall whatsapp, if you have a copy of your latest. msgstore.db .crypt12 file, (found on your Whatsapp folder in your SD card under Databases) copy it from there to your internal memory Whatsapp Database folder. Please note that any existing msgstore.db .crypt12 file must first be deleted. Go to your SD card whatsapp folder named backup and copy the backup crypt file as well to the internal memory whatsapp folder only after deleting the existing folder. Install whatsapp and authenticate the install , do not accept the backup prompt. Once installed go to Chats and run a backup to google drive. Your key is in the DB files and will be uploaded to google drive along with all backuped data. Uninstall Whatsapp and reinstall, this time accept the backup prompt. Verify that the two files that you copied still exist in both the SD and internal memory, allow a normal backup to occur at 4am and check in the morning. All files should be recovered and the old key should be reinstalled.
31st January 2019, 08:54 PM |#10  
Junior Member
Thanks Meter: 0
 
More
Thank you very much for your guide. I upgraded a phone to a custom rom and even though I made a recent in-app backup and never used another phone number/sim card, Whatsapp was not able to restore the data.
Glad I made a complete NAND backup just to be safe....
10th April 2019, 07:15 PM |#11  
Senior Member
Thanks Meter: 46
 
More
@sexler (what a name )
THX a lot for your guide!


I changed from Android 7 (LineageOS) to Android 8.1 (CarbonRom) without using Google-Apps anymore. So no Backup from the cloud would be possible.
Only the "c) Start WhatsApp and activate it." was not possible with my Whatsapp. But I just did the activation later and after that he noticed that there where a backup.



Your guide helped out of my 7 days quest
THX THX THX!


Greetings by Idijt
Post Reply Subscribe to Thread

Tags
whatsapp

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes