Skip to content

Instantly share code, notes, and snippets.

@xnumad
Created October 22, 2019 22:45
Show Gist options
  • Save xnumad/96a4b15d63a3dad5cce2b2663f5fcd08 to your computer and use it in GitHub Desktop.
Save xnumad/96a4b15d63a3dad5cce2b2663f5fcd08 to your computer and use it in GitHub Desktop.
WhatsApp message backup and restore process

If you activate WhatsApp (verifying your phone number) while having a /sdcard/WhatsApp/Databases/msgstore.db.crypt12 file present AND have a WhatsApp backup on Google Drive, WhatsApp will claim to restore your Google Drive backup (with your consent), but it only restores the media files from Google Drive but at no occassion the msgstore.db.crypt12. It won't merge your local backup and the cloud backup databases!

With local WhatsApp media files it will only offer to restore the local backup at activation but not the one from Google Drive, hence the need for an empty /sdcard/WhatsApp/Media/ folder. But with a local chat backup, the Google Drive backup restore process just imports media only anyways.

Ways to get to the key file to decrypt the *.crypt12 DBs:

  • either access /data/data/com.whatsapp/files/key with root permissions
  • OR adb backup com.whatsapp and extract the key from the .ab file

I have extracted the key and found out that it's the same for all my devices (I always tested with the same phone number). For the decryption and restoring of the locally saved msgstore.db.crypt12 (like described above), it is also automatically saved on WhatsApp servers.

@palladidrago
Copy link

palladidrago commented Nov 13, 2020

According to what i found out whatsapp doesn't allow backups in its manifest, so you would need to decompile and recompile the app.

@YuvrajRaghuvanshiS
Copy link

According to what i found out whatsapp doesn't allow backups in its manifest, so you would need to decompile and recompile the app.

It doesn't now, you can use https://github.com/yuvrajraghuvanshis/whatsApp-Key-Database-Extractor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment