4

I'm using Whatsapp from a virtual machine since I lost my phone, and now need to transfer it to a new VM.

The easy way would be to use the backup feature native to Whatsapp, but it is disabled since the VM is connected via Ethernet (and Android thinks it's a Mobile connection). In fact the very "local backup" feature is not available. I have a ton of messages which I really wouldn't like to lose.

There's an Xposed module which could possible fake an Wifi connection in the Android VM, but at this point I really want to do the entire transfer locally as my internet is painfully slow right now.

I tried the built-in adb backup feature, only to find out it's disabled for Whatsapp and can't be easily enabled (requires decompiling the apk file).

So, how can I manually transfer Whatspp app data to the new "device"? What folders do I need to copy, and what files must be modified in order for the transfer to work seamlessly?

I do of course have full root access.

[Update] Neither of the following work:

  • Copying the entire contents of /data/data/com.whatsapp/databases after installing Whatsapp, signing in and closing it. It will crash when opening, without any error message.

  • Copying the same directory, but without opening Whatsapp and signing in after installation. Same error as above.

  • Copying /data/data/com/whatsapp/databases/msgstore.db after installing Whatsapp and signing in. An error message is presented: "Something went wrong with your chat history"

  • Copying the entire /data/data/com.whatsapp directory, after installing and closing it. It will crash when opening, without any error message.

3
  • The concept would be to create a TAR archive of anything under /data/data/com.whatsapp (in order to preserve the permissions and ownerships). Then, you'll need to install WhatsApp on the new host machine, and lastly you should untar the previously created archive under the /data/data/com.whatsapp directory of the new machine, overwriting all of the files that'll be already there. This should emulate the backup operation performed by a dedicated app, but remembered that this is a mere concept I didn't test yet.
    – Grimoire
    Jul 6, 2016 at 9:39
  • @DeathMaskSalesman I did try, unfortunately that doesn't seem to work. The app will crash when I try to open it.
    – Marc.2377
    Jul 7, 2016 at 2:53
  • Don't you have root? If you do, you could use some application like Titanium Backup. It's been a while since I last used Android, but copying apps, especially Whatsapp, will hardly work for apps such as Whatsapp, Facebook or Messenger. Nov 17, 2017 at 23:04

5 Answers 5

3

I was encountering the crashing behaviour trying these approaches too, but @DeathMaskSalesman seems to've been on the right track—the crashes are indeed a permissions issue.

If you remove WhatsApp entirely, reinstall it, and copy /data/data/com.whatsapp over and adjust the permissions correctly before launching it the first time, then it should just need to reverify your number to work. This worked for me.

To adjust permissions, first use ls -la to check the permissions on what's put in the /data/data/com.whatsapp directory upon install, e.g.:

drwxrwx--x   3 u0_a105 u0_a105  4096 2018-07-14 00:55 cache

Then use the username and group (here both u0_a105) to rename the files after you've copied them in:

chown -R u0_a105:u0_a105 /data/data/com.whatsapp/*

Then WhatsApp should launch okay without crashes, and retain settings, messages, and multimedia.

3
  • 1
    Thanks, I'll try this the next time. Makes sense and should work, I'm accepting this answer.
    – Marc.2377
    Jul 14, 2018 at 22:46
  • 1
    @Brune, this sounds like something worth asking as a separate question. Aug 28, 2020 at 1:04
  • This works perfectly! When I only move the data the app crashes if the devices has different users/groups names from original device. But after I set the username and group it works, thanks @JonathanW.
    – Bruno
    Nov 15, 2022 at 13:55
4

If you have root, you can use TitaniumBackup to save Whatsapp data.

If you don't have root, you can downgrade to Whatsapp 2.11.431 (you can find it here) which was the latest version with adb backup feature activated, and then proceed backing up with adb (instructions).

2

THX to this guide here from xda I was handle to perform a manually transfer of my entire Whatsapp conversations (120000 messages :D).

Simple:

  1. Make a full TWRP Backup of your old rom if possible +pull it with adb or MTP from your phone
  2. Copy with TWRP Terminal, TWRP Filemamanger, ADB or with your running system with root access this file: /data/data/com.whatsapp/files/key
  3. Check the filesize of that key-file. It should be 158 Bytes. If there are multiple, choose them all. But later you need the one with 158 Bytes.
  4. Copy the key file and the Folder /sdcard/Whatsapp to your local-machine.
  5. On your new phone: Install Whatsapp and open it but do nothing more. Let it open and hold the power-button to shutdown or restart into your TWRP recovery.
  6. Within TWRP push "Whatsapp" folder with all it's content to your /sdcard/ folder and psuh the key file (that one with 158 Bytes) into /data/data/com.whatsapp/files/
  7. Start your new phone again and start Whatsapp. Press restore, if you got the message that it does not found anything in "/sdcard/Whatsapp/backup", go ahead and verify your number. In my case WA found the database then and restored my 120000 messages.

If I understand that right:

  • /data/data/com.whatsapp/files/key Is the encrypton key for your database with all your messages.
  • /sdcard/Whatsapp/Databases/msgstore.db.crypt12 Should be your database with all your messages in it. There could be some more with a date in the filename. These should be smaller and older then the msgstore.db.crypt12.
  • /sdcard/Whatsapp/Media Contains media :-P If you lost this, only the messages would be there and the media had just nothing to link to it.

I am happy now. I was able to switch from Android 7 (LineageOS) to Android 8.1 (CarbonRom) without using Google-Apps anymore. So no Backup from the cloud would be needed. MicroG has a bug with that.

0

You can find WhatsApp data in the directory /data/data/com.whatsapp, just copy all the contents of subdirectory databases with adb pull /data/data/com.whatsapp/databases and transfer it onto your new VM with adb push path/to/saved/databases/directory /data/data/com.whatsapp/databases, be sure the target it's empty.

7
  • Thank you for your answer. I'm guessing I must first install Whatsapp on the new VM, right? Or should I create the /com.whatsapp/databases manually as the first step?
    – Marc.2377
    Jul 5, 2016 at 23:17
  • Yes, you must install WhatsApp, then register your account as usual, that will create the com.whatsapp folder and its contents.
    – boxHiccup
    Jul 6, 2016 at 13:56
  • Unfortunately it didn't work. I get the following message when attempting to open Whatsapp: "Something went wrong with your chat history".
    – Marc.2377
    Jul 7, 2016 at 2:54
  • There is any difference between WhatsApp versions in both VMs?
    – boxHiccup
    Jul 7, 2016 at 6:09
  • No, it's the same version.
    – Marc.2377
    Jul 7, 2016 at 8:23
0

I used to backup only the msgstore.db file located in /data/data/com.whatsapp/files before uninstalling, and copying it to the same folder after new installation. But this doesn't seem to work anymore since version 2.19.xx.

From the comments, I think key file is the new factor here. Will try.

1
  • Was the key file the new factor? I also used to backup msgstore.db but then realized it had become insufficient. Now I'm not sure what to backup to avoid saving the whole com.whatsapp folder yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .