[Guide] Whatsapp - manually restore messages with just /data/data/com.whatsapp (root)

Search This thread

pipera

New member
Mar 11, 2020
1
7
I needed to restore my Whatsapp messages without having a proper whatsapp backup, in cloud or local, just a TWRP data partition backup (without userdata, thanks to encryption and some other unrelated problems), so, having only data/data/com.whatsapp directory with the unencrypted databases and files to work with, the usual solutions discussed here weren't an option. In my case, fully replacing the com.whatsapp folder and changing its permissions, as some other sources recommend, resulted in Whatsapp crashing for reasons I ignore. Such info was on the right track and after trying all kind of stuff I finally was able to restore my messages. My steps were as follows, hopefully it works for you too:

Requirements:
  • A backup of /data/data/com.whatsapp, it should have the databases and files subdirectories.
  • Rooted Android phone with Whatsapp uninstalled.
  • Basic terminal usage knowledge. (Should be possible to do it with a decent enough file browser but I won't cover it, feel free to adapt it)
If you need to manually extract com.whatsapp from a TWRP backup:
  1. Locate the different data.ext4.win### files in the TWRP backup.
  2. Rename them adding .tar at the end of the name and open them with Winrar/7zip.
  3. If the .tar contains another data.ext4.win###, extract it and repeat the process.
  4. Once you have access to the actual contents inside the files, locate the file which has the data/data/com.whatsapp directory.
  5. Extract that com.whatsapp directory.
Once you have your copy of com.whatsapp:
  1. Copy your backup of com.whatsapp directory to your phone (I will use /sdcard/com.whatsapp as example).
  2. Install Whatsapp but DO NOT RUN IT. Try to use the same version. (Probably works between versions to some extent)
  3. Install an Android terminal emulator and launch it. (Tested with termux)
  4. Elevate, enter /data/data and show the permissions of the installed Whatsapp com.whatsapp directory:
    Code:
    $ su
    # cd /data/data
    # ls -ld com.whatsapp
  5. You'll see something similar to:
    Code:
    drwx------ 10 u0_a117 u0_a117 4096 2020-03-09 17:28 com.whatsapp
  6. Take note of the user/group, will have u0_a# format. (In my case will be u0_a117)
  7. Enter into that directory:
    Code:
    # cd com.whatsapp
  8. Copy files and databases directories from your transferred com.whatsapp copy in step 1 to your install location. (Don't forget the final space and dot)
    Code:
    # cp -R /sdcard/com.whatsapp/databases .
    # cp -R /sdcard/com.whatsapp/files .
  9. Change both directories owner and group to the one seen in step 5.
    Code:
    # chown -R u0_a117:u0_a117 databases
    # chown -R u0_a117:u0_a117 files
  10. Check the permissions to be 100% sure that the user/group are correct.
    Code:
    # ls -lad *es
  11. Launch Whatsapp.
  12. Whatsapp will ask you to configure your phone number. Once you're done, you'll see your messages right there.

If Whatsapp crashes after launching it, you wrote a wrong user/group when changing permissions. Whatsapp overwrites the contents of com.whatsapp before crashing, so you'll need to reinstall Whatsapp and start again. The user/group will be a different one each time you install it.
 

Yaagod

New member
Sep 27, 2020
4
0
My system was buggy, not being possible to boot and backup via TitaniumBackup or similar..
I tried your method and worked perfectly via OrangeFox Recovery (with the terminal and the included file manager that facilitates copy/paste operations)
Thank you very much!!
 

agustincordoba

Senior Member
Sep 27, 2009
202
35
Thank you for this tutorial. I have the same difficulty as the first respondent, in that my miui system is buggy and constantly restarting so no time to do a chat backup with the normal procedure. I also have orange fox recovery so I shall try to follow your instructions to the detail. Hopefully all will go well; I shall post back later with the results.
 

agustincordoba

Senior Member
Sep 27, 2009
202
35
My system was buggy, not being possible to boot and backup via TitaniumBackup or similar..
I tried your method and worked perfectly via OrangeFox Recovery (with the terminal and the included file manager that facilitates copy/paste operations)
Thank you very much!!

Did you introduce any variation or it worked straight off?

One thing that worries me is checking all the permissions
 

MLX

Senior Member
Mar 12, 2016
192
52
21
Buenos Aires
Thanks a lot! I'd just drop my device and it's screen broke, and I was able to "transplant" my WhatsApp installation to another device just fine!
I was trying something similar to this long ago (but also copying some whatsapp-related files from /data/user/0/) and it didn't work, maybe they were related to authentication? Anyway, if it works I don't care :p
 

david_lev

New member
Apr 14, 2019
2
1
davidlev.me
Very nice guide.
you can skip the chown part and use
Code:
cp -rp databases files  /data/local/tmp/
to keep the permissions and ownership.
And i think that
Code:
pm clear com.whatsapp
will do the work, you don't need to uninstall if the app opens after the installation.
 
  • Like
Reactions: raz123

Trolli91

New member
Apr 4, 2012
3
3
I just want to say a big THANK YOU. I can confirm that it's still working.

As I have no root on my phone I have used the internal Terminal of TWRP Recovery instead of an app and executed the commands there. They were running without problems (except the command "su" of course) and WhatsApp recognized my previous data.
 

JackDCalloway

Senior Member
Custom ROM died yesterday, not able to do backups, recovery had problems too, so I managed to find some Whatsapp inside a TWRP Backup.
I'm unable to work with terminal, can't change directories, maybe because of Android 13. But with total commander app I'm able to move file and database folder and rearrange owner, group and permissions. at least I'm pretty sure to get it right. whatsapp still crashes.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    I needed to restore my Whatsapp messages without having a proper whatsapp backup, in cloud or local, just a TWRP data partition backup (without userdata, thanks to encryption and some other unrelated problems), so, having only data/data/com.whatsapp directory with the unencrypted databases and files to work with, the usual solutions discussed here weren't an option. In my case, fully replacing the com.whatsapp folder and changing its permissions, as some other sources recommend, resulted in Whatsapp crashing for reasons I ignore. Such info was on the right track and after trying all kind of stuff I finally was able to restore my messages. My steps were as follows, hopefully it works for you too:

    Requirements:
    • A backup of /data/data/com.whatsapp, it should have the databases and files subdirectories.
    • Rooted Android phone with Whatsapp uninstalled.
    • Basic terminal usage knowledge. (Should be possible to do it with a decent enough file browser but I won't cover it, feel free to adapt it)
    If you need to manually extract com.whatsapp from a TWRP backup:
    1. Locate the different data.ext4.win### files in the TWRP backup.
    2. Rename them adding .tar at the end of the name and open them with Winrar/7zip.
    3. If the .tar contains another data.ext4.win###, extract it and repeat the process.
    4. Once you have access to the actual contents inside the files, locate the file which has the data/data/com.whatsapp directory.
    5. Extract that com.whatsapp directory.
    Once you have your copy of com.whatsapp:
    1. Copy your backup of com.whatsapp directory to your phone (I will use /sdcard/com.whatsapp as example).
    2. Install Whatsapp but DO NOT RUN IT. Try to use the same version. (Probably works between versions to some extent)
    3. Install an Android terminal emulator and launch it. (Tested with termux)
    4. Elevate, enter /data/data and show the permissions of the installed Whatsapp com.whatsapp directory:
      Code:
      $ su
      # cd /data/data
      # ls -ld com.whatsapp
    5. You'll see something similar to:
      Code:
      drwx------ 10 u0_a117 u0_a117 4096 2020-03-09 17:28 com.whatsapp
    6. Take note of the user/group, will have u0_a# format. (In my case will be u0_a117)
    7. Enter into that directory:
      Code:
      # cd com.whatsapp
    8. Copy files and databases directories from your transferred com.whatsapp copy in step 1 to your install location. (Don't forget the final space and dot)
      Code:
      # cp -R /sdcard/com.whatsapp/databases .
      # cp -R /sdcard/com.whatsapp/files .
    9. Change both directories owner and group to the one seen in step 5.
      Code:
      # chown -R u0_a117:u0_a117 databases
      # chown -R u0_a117:u0_a117 files
    10. Check the permissions to be 100% sure that the user/group are correct.
      Code:
      # ls -lad *es
    11. Launch Whatsapp.
    12. Whatsapp will ask you to configure your phone number. Once you're done, you'll see your messages right there.

    If Whatsapp crashes after launching it, you wrote a wrong user/group when changing permissions. Whatsapp overwrites the contents of com.whatsapp before crashing, so you'll need to reinstall Whatsapp and start again. The user/group will be a different one each time you install it.
    1
    Very nice guide.
    you can skip the chown part and use
    Code:
    cp -rp databases files  /data/local/tmp/
    to keep the permissions and ownership.
    And i think that
    Code:
    pm clear com.whatsapp
    will do the work, you don't need to uninstall if the app opens after the installation.