[GUIDE] Merge Multiple Whatsapp Backup File Into One (No Root Required)

Search This thread

sieger007

Senior Member
Jul 4, 2008
322
32
Dublin
I could manage to merge to an encrypted databases .
just give a brief two liner for my situation.
I had a situation where my db crypt files were not available and all I had wss the internal data msgstore.db located at
/data/data/com.WhatsApp/databases

the original file was 780mb I will just call it 780mb.db
when WhatsApp did a restore from Cloud something wrong happened and and I am missing about six months of data and the current
msgstore .db is just 380mb. call it 380mb
db

so the latest msgstore.db file is about 400 MB short and this maps to more than 6 months of chat history which is missing currently when WhatsApp messages are restored.

I followed the procedure to merge the two database files I have not followed any decrypting procedure because this is the un encrypted file
this included running the update on the New database files ( in sqllite database editor ) so the last message of the old one is in immediate precedence to messages in the new one.
new merged.db fiile was copied
to

/data/data/com.WhatsApp/databases

WhatsApp app was stopped and cache was flushed

on restarting it gave me a message there is a problem with your chat history don't worry we will restore it that is it refused to read the merged.db ( now.msgstore.db ) and it's simply renamed it as
now , msgstore.db. corrupt

now I repeated the same procedure in airplane mode and it it would read that file I could see my messages but WhatsApp would immediately crash
here is the crash information
it says database malformed image but I can open this database easily in my PC sqllite browser

I have tried this several times and I have on able to incorporate the data that is there in 780mb.db file to the current msgstore.db

any moolah on this ?
 

Attachments

  • Screenshot_20190803-135703.jpg
    Screenshot_20190803-135703.jpg
    116.4 KB · Views: 632
  • Screenshot_20190803-135646.jpg
    Screenshot_20190803-135646.jpg
    122.2 KB · Views: 616

SEETIW

New member
Aug 8, 2019
1
0
I have old.db, new.db and merjapp stored in a folder called Merge on the desktop. However, I get the following response:-

C:\Users\simon>cd desktop

C:\Users\simon\Desktop>cd merge

C:\Users\simon\Desktop\Merge>java.exe -jar merjapp.jar -old old.db -new new.db
-E- Database old.db cannot be found!

Anyone any idea why this is so?
 

Chester89

New member
Sep 28, 2014
2
0
Whatsapp don't found merged db

Hi Guys,
I have finally got my merged db, than I renamed "msgstore.db", then I copied it in "/storage/emulated/0/WhatsApp/Databases/" but when I'm going to reinstall Whatsapp (Ver. 2.19.230) the app don't found any backup.
I think the problem is that my merged db is not encrypted in crypt12.
I read in previous messages to try to use Yowhatsapp, which should be able to restore an unencrypted db and then to create a crypt12 backup from it.
My phone is OnePlus X (not rooted), can anyone help me please?
Thanks.
 

silver-knight

Member
Aug 31, 2013
6
0
Restoring deleted chats

I have a backup of a DB file containing chats I deleted a long time ago, memories I didn't want infront of me at the time, but now I wish to restore.
Apparently nothing really gets deleted as the messages are still included in the DB forever, but are not visible within the WhatsApp app.
I tried exploring the DB file with SQL but couldn't find anything to hint about what makes a message (or chat) visible or not.

Anyone has tips as to how to restore a chat I deleted?
(to clarify I decrypted the DB and have full access to it - so I'm passed that phase)
 

115irfan

New member
Oct 7, 2019
1
0
Hey I'm getting an error in command like -
"'java.exe' is not recognized as an internal or external command,
operable program or batch file."

Please tell me where I'm wrong?
 

borgqueenx

Senior Member
Jun 25, 2008
713
34
Hello. I have restored a iphone backup to android and now see months later that it didnt import the media files.
So how can i import iphone whatsapp media files from the media folder into my current android? (so no replacing or new messages)

Thanks!
 

Sourabh Gharde

Senior Member
May 13, 2017
234
48
Sonipat
Samsung Galaxy M21
Can I merge backups from 2 different devices?
I used WhatsApp with the same no when I broke my old android and made a fresh start in a new device with the same number. I have repaired my old device and now I want to merge both backups.
 
  • Like
Reactions: diyabolic

ykkfive

Inactive Recognized Developer
Jul 25, 2010
3,220
3,018
ykkfive.blogspot.com
Can I merge backups from 2 different devices?
I used WhatsApp with the same no when I broke my old android and made a fresh start in a new device with the same number. I have repaired my old device and now I want to merge both backups.


i am facing this problem too since i used to have 2 devices running whatsapp with one single phone number. here's what i am going to do:

##### NOTE for dbs containing different msgs from different devices only (using 2 devices simultaneously with one phone number, eg device a in day time and device b at night at home), not for merging 2 old dbs (eg before 2018 and after 2018) into 1

# let db from device a be a.db, and b.db from device b
since they contains almost same group of people but with different ids , i have to do something to sync them first
aim: to merge 2 db into one with unique people and sort all merged records by date time (i have done a test before , sorted by date but without rewriting the msg id, thus making newer msgs appeared in between the old msgs )

- increment the people id,msg id, attchment id etc say by 30000 from b.db in all tables
- replace people ids from a.db for all tables ib b.db
- import msg records from a.db and b.db to a new c.db, just play it safe
- now i should have a table with all msgs from a.db and b.db in c.db
- sort all records in c.db by date time to rebuild all the records in sequesnce
- reapply a new msg id to all msg records according to the date time, and replace all old msg with these new ids, probably needs to subtract 30000 added above


i believe the above steps will do but worrying about the attachments etc, and there are many unused tables

what do you think?



edit sorry, may be this is not useful for you, i misread your message. what you need is something like a concat
 
Last edited:

johnnydoughnut

New member
Jan 22, 2020
2
0
Quoted texts are wrong?

Managed to merge the 2 databases but noticed the chats where I quoted someone were wrong. The normal texts are okay it's just that the quoted message is like a message from about 2 years ago. Anyone know how to fix this?
 

ykkfive

Inactive Recognized Developer
Jul 25, 2010
3,220
3,018
ykkfive.blogspot.com
I'm having trouble merging the new and old db. A java error is thrown:
Code:
C:\Users\JK\Desktop\merge>java.exe -jar merjapp.jar -old old.db -new new.db
Exception in thread "main" java.lang.SecurityException: Prohibited package name:
 java.sql
        at java.base/java.lang.ClassLoader.preDefineClass(Unknown Source)
        at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
        at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)

        at java.base/java.net.URLClassLoader.defineClass(Unknown Source)
        at java.base/java.net.URLClassLoader.access$100(Unknown Source)
        at java.base/java.net.URLClassLoader$1.run(Unknown Source)
        at java.base/java.net.URLClassLoader$1.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.net.URLClassLoader.findClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)

C:\Users\JK\Desktop\merge>java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

any ideas how to solve this problem?



incorrect java version
try 1.8x

---------- Post added at 03:03 ---------- Previous post was at 02:56 ----------

But i have no idea who can I merge two & three whatsapp backup file in my new device
Pls help me
I will pay charges for it
Amit dhanuka
Fatehapur shekawati
Sikar rajasthan
India
Mobile:-9571137171
Mail id:-amitdhanuka1992@gmail.com

I was successfully able to do all the above steps and restore my merge whatsapp backup via YoWhatsApp. But, I noticed an issue with the merged msgstore.db file. After restoring the chats, they were not organized properly. Chats from different people and groups were merged randomly. For instance; replies to messages in group 'A' were showing in chat of person 'B and so on'.

Maybe this can be a sync issue or an indexing issue. I can see media files have been carried forward correctly and time stamps on the older chats (old backup) are correct but then there are no time stamps on new chats (new backup)

I checked the _id in chats and there are no overlapping ID's on anyone.

Is there a way to fix these chats or the backup file by any kind of tool.

Managed to merge the 2 databases but noticed the chats where I quoted someone were wrong. The normal texts are okay it's just that the quoted message is like a message from about 2 years ago. Anyone know how to fix this?





i had problems merging 2 dbs, so i read the sources and performed the steps manually. i found there are a few bugs, and seems that some tables, including chat_list were left untouched or not updated completely/properly (it's still in beta). may be that's why you have chats history/quoted msgs problems

ps i am trying to merge 2 dbs manually but facing some problems but i think i can handle them sooner or later. however my current solution is solely based on my dbs only and thus not a universal solution since there are too many tables involved and most of them are empty, at least for me. what i mean by it's not a universal solution because, eg if you have group charts but i don, then my solution wont work for you since i don have such entries in my db and therfore i have no way to trace them with my own db atm. also, for my dbs the entries are not in sequential order but are separated across the 2 dbs since i was using my phone at day time but my tablet at night . so you can imagine that one conversation may be stored in 2 dbs and i have to deal with that also
 
Last edited:

d33pxd

New member
Mar 4, 2020
1
0
Is it possible to merge an older backup from my previous rooted android phone (key file is available) with a newer backup from my present android phone (key file also available). The phone number is the same.

And just out of interest: is the key file the same on different phones with the same number or depends the key file on the phone (or both?)
 

selemine

Senior Member
Nov 22, 2011
139
34
POCO X4 Pro
If i have the current whatsapp folder with a lot of msgstore*db.crypt12 and the MediaFolder and an outdated backup of the /data/data/ folder with the key file in it, would it work if i just copied the msg store. crypt12 and the media folder back to get a working up to date state of the conversations or are the files more interlinked with each other?
 

sieger007

Senior Member
Jul 4, 2008
322
32
Dublin
I am not sure if I post at the right place but I would like to share this to everyone as I understand how hard it is to find a solution that works. With this guide, you will get to keep the original WhatsApp .....[/SIZE]


Hi Wanted to know if this still works.
I tried it long ago with 2 UN encrypted msgstore.db files but the new file wasn't liked by WhatsApp. It gave me error. Malformed database error and whatsapp crashed.
Q - What makes whatsapp think a certain database is good vs malformed. Some kind of key needed ? and does it change from phone to phone ? Different ROM instance installs on the same phone ?
Any idea
 

gramouk

Member
Jan 21, 2019
34
0
Hello,
Does this program even work on win10? When I run it nothing happens on my phone and the extracted folder stays empty even after the terminal work....
My phone is on LOS.
Might give it a try on ubuntu
 

secondchild

New member
May 1, 2020
3
0
The instructions by DLz88 in post 17 are still working, as long as your phone is not running on Android 7 or higher.
Phase 2 can (or actually should be skipped). Enough with phase 1 and 3. merjapp is handling the renumbering of the chats. However, that is if you don't have overlapping dates of your chats between your old and new backup. If dates are overlapping you might need to do some magic in SQlite browser. (For me that was not any issue though).
For phase 1 - decryption: Use a phone with Android 6 or less. 7 or 8 does not seem to work. The problem is when installing the legacy 2.11 which will not be allowed in Android 7 or higher. So look deep into your drawers, or buy an old Z1 compact (which is the phone I found in my drawer) :)
In phase 3 the correct command line is java.exe -jar merjapp.jar -old old.db -new new.db
(it was missing a space after merjapp.jar)

Afterwards you might need to have a rooted phone and follow the instructions in post 37
Or, if you have an old phone like me, just do a factory reset (do it as clean as you can. I used Xperia Companion on my PC which makes it totally clean installation).

For Media, just copy the two media folders that you have into a new folder. If it asks for replacing files, then just check what files it is (normally it is the .nomedia files).

Oh, and just so you know. The new version of whatsapp does not allow you to backup from a local storage on your phone. You need an older version of whatsapp for that. Here is a link to 2.17.422 that will work.

I saw another post where someone confirmed that this solved their problem. However, WhatsApp 2.17.422 no longer works (it gives the well known "adjust date and time" error that you can't move past). I also tried other WhatsApp versions with release dates prior to your post and had the same issue. So, are there any other options for restoring my merged database on an unrooted phone? It took ages to successfully extract the backup file from one of the phones due to various errors but I got there in the end and had a successful merge (all thanks to this forum). It would be a shame not to be able to use it.
 

alexbit

Member
Sep 28, 2007
21
0
Goodmorning everyone.

I have a problem while using the tutorial :(

I have a Huawei Nova 5T with android in version 10 that broke the display a few weeks ago.

Now I have replaced the display and so I have back again the access to the smartphone and I would like to transfer and merge the whatsapp db on that phone with the other one on the phone that I'm since I broke the Nova .
Well ... I downloaded and installed WhatsApp-Key (version 4.7) on my laptop with Windows 10 home. I launched it and I've connected the old phone that but the program gave me this error:

Code:
Installing legacy WhatsApp 2.11.431
3 KB/s (251 bytes in 0.062s)
Error: Failed to parse APK file: /data/local/tmp/LegacyWhatsApp.apk

Exception occurred while executing:
java.lang.IllegalArgumentException: Error: Failed to parse APK file: /data/local/tmp/LegacyWhatsApp.apk
        at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:484)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1073)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:177)
        at android.os.ShellCommand.exec(ShellCommand.java:104)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23851)
        at android.os.Binder.shellCommand(Binder.java:888)
        at android.os.Binder.onTransact(Binder.java:772)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4879)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4538)
        at com.android.server.pm.HwPackageManagerService.onTransact(HwPackageManagerService.java:505)
        at android.os.Binder.execTransactInternal(Binder.java:1028)
        at android.os.Binder.execTransact(Binder.java:1001)
Caused by: android.content.pm.PackageParser$PackageParserException: Failed to parse /data/local/tmp/LegacyWhatsApp.apk
        at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1854)
        at android.content.pm.PackageParser.parseApkLite(PackageParser.java:1839)
        at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:477)
        ... 11 more
Install complete

Now unlock your device and confirm the backup operation.

Please enter your backup password (leave blank for none) and press Enter:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.RuntimeException: java.lang.NumberFormatException: For input string: ""
        at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:420)
        at org.nick.abe.Main.main(Main.java:128)
        ... 5 more
Caused by: java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:280)
        ... 6 more
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now

Cleaning up temporary files ...

File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\whatsapp.ab
File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\waplen.txt
File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\sdpath.txt
File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\wapath.txt
File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\wapver.txt
File eliminato - C:\Users\aless\Desktop\WhatsApp-Key-DB-Extractor-master\tmp\sdkver.txt

Done

Restoring WhatsApp 2.20.157

Could someone help me?
 

Fish_scale

New member
Jul 2, 2020
1
0
Could you share your experience with the rest of us?

I am just about thinking of merging two what's up databases.

And it seems like the tutorial from 2016 will not work without a million errors due to version changes.
 

alexbit

Member
Sep 28, 2007
21
0
Could you share your experience with the rest of us?

I am just about thinking of merging two what's up databases.

And it seems like the tutorial from 2016 will not work without a million errors due to version changes.

Hi!
NO experience till now... I've started follow the guide but I immediately got the above error... then all the rest of the process fail.
I've also post my question here: https://xdaforums.com/showthread.php?t=2770982&page=60#post82917051.
Hopeful to get any help. It's really very annoing that it's so hard to merge whatsaspp databases!
Please share any solutions... ;)
 

Black Swift

Senior Member
Jan 24, 2015
73
1
30
San Jose
Hello!!
so ,my phone battery died, and i had to wait a couple of monts before i could get a new battery and fix it, meanwhile i started using a new cheaper phone, but unfortunately the backup didnt worked and i lost all my chats.

but today i went back to my old phone and found out all the chats are rigth there, didnt lose anyting, but dont have all the chats i had on my cheaper phone,

is there any way to restore the chats from the cheap phone to the old one whitout losing anyting? like merrging the backups or someting?

or simply by runing a restore of the google backup i get everyting witout losing anyting??
 

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    I am not sure if I post at the right place but I would like to share this to everyone as I understand how hard it is to find a solution that works. With this guide, you will get to keep the original WhatsApp message information (such as thumbnail, link, emoticon, etc.) and work like it is a restore file that backup from itself.

    There will be three main phase you need to perform. You can get all required file in the attachment. Make sure you backup your end result before jump into the next phase.

    Phase A: Decrypt and obtain msgstore.db file
    This is the easiest method I can find and NO ROOT is required to perform this. All you need is to follow the instruction below.

    INSTRUCTIONS:
    1. Extract "WhatsAppKeyExtract.zip" (from attachment) on your computer maintaining the directory structure.
    2. Browse to the extracted folder and click on "WhatsAppKeyExtract.bat".
    3. Enable USB Debugging on your device.
    4. Connect your device via USB**, unlock your screen and wait for "Full backup" to appear.
    5. Leave the password field blank and tap on "Back up my data".
    6. The "extracted" folder will now contain your "whatsapp.key", "msgstore.db" and "wa.db".
    **If you have never used USB Debugging before, you may also need to verify the fingerprint.

    (Credited to TripCode for providing this application! Here is the link to original thread.)

    For my case, I have three backup files that named msgstore.db.crypt, msgstore.db.crypt7 and msgstore.db.crypt8. Although I know there might be other easier method to achieve this, I choose to restore each file (by uninstall and install WhatsApp) and run the above method to get my decrypted file. Hence I can be sure that all decrypted file will come in the same structure (I will show you what this mean later) and prevent any error that may cause by that.

    Phase B: Edit and prepare database for merge
    This will be a bit tricky. But in general, you MUST make sure that you have no overlapping message history between your files.

    INSTRUCTION:
    1. Download SQLite Database Browser and install on your computer.
    2. Open the database you want to edit.
    3. Click on [Browse Data] tab.
    4. In Table drop down menu, click on [messages] (You will see all your WhatsApp message here).
    5. Use it like you are using Excel, select any row that is overlapping (EXCEPT the row with many [-1] value) and click on [Delete Record], then click on [Write Changes] (this means you have save the change to the database).
    6. Keep doing this for your remaining file and close all windows of SQLite Database Browser when you are done.
    (Thanks ztedd for posting his own method where I get inspired from. This is the link to his original post.)

    For my case, the number of column of all my file when display in "messages" table is different (newer WhatsApp database file have more data type). This is the reason I restore and run backup again to make sure all my file have the same structure. Also, a quick tips to figure out which row is overlapping or duplicate is export the messages table to CSV file and open it with Excel. You will need to copy the first few column of each database and paste them together, then use the feature that come with Excel such as Filter and Remove Duplicate to identify which row number you need to remove from actual database file.

    IMPORTANT - Never edit your database on excel and import it back to your original database. This will remove all thumbnail, link, emoticon and etc. and show you some weird message when you restore back to your device.

    Phase C: Merge database file
    This method only can merge two file at once. You may need to do this several time depending how many database you want to merge. I suggest you start from the oldest to newest.

    INSTRUCTION:
    1. Rename the older file to old.db.
    2. Rename the newer file to new.db
    3. Create a new folder called Merge and copy the file old.db, new.db and merjapp.jar into it.
    4. Run Command Prompt on your computer (or click on Start Menu and search for cmd)
    5. In Command Prompt, type each of the following separately and press Enter:
      Code:
      cd desktop
      
      cd merge
    6. You now should see [C:\Users\<UserName>\Desktop\Merge>] in cmd window.
    7. Now type the following and press Enter:
      Code:
      java.exe -jar merjapp.jar -old old.db -new new.db
    8. You should see a "Done!" is displayed and a new file named output.db will be created in the Merge folder.
    9. If you have other database to merge, repeat the steps above by rename the output.db to old.db.
    10. Once you are done, rename the output.db to msgstore.db and it is ready to restore into WhatsApp.
    (Credited to namnoops for this merge application! This is the link to original thread.)

    For my case, I have to run this steps twice to merge 3 databases. I get error the first time I run this because some messages is overlapping and this is the reason for Phase B to edit my database. Once I got my merged database, I renamed it to msgstore.db (without encrypt again) and have no problem restore back to my device. I also copy and paste all my backed up WhatsApp folder to my device (except the file in Database folder) for the picture in WhatsApp to work.

    Disclaimer: I do not know any coding behind all these so if you have any questions I will try to answer but the best bet is to go back to the original thread.

    Below is some other method that I found online but can't figure out how to do it. You may try it at your own risk.

    Additional Method:
    sch3m4's wforensic Method
    Alternate sch3m4's wforensic Method
    6
    Guys, I have FINALLY found a way to merge two differten WhatsApp backup files. I'll post the guide asap (have to translate it). Is different from the one on the first page for the first two parts.

    How to merge two different WhatsApp backup files:

    We have two different WhatsApp backup file (doesn't matter if encrypted by different methods, for example, I had a crypt9 file and one crypt8) and we want to combine them into one so we can read them with WhatsApp.

    Requirements: OS: Windows Vista, Windows 7 or Windows 8

    Programs you need:

    1) WhatsApp Xtract: http://xdaforums.com/showthread.php?t=2770982

    2) SQLite Database Browser: https://github.com/sqlitebrowser/sql....2.0-win32.exe

    3) merjapp (merjapp.jar) https://github.com/namnoops/merjapp/releases

    4) JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    5) Java: https://www.java.com/en/download/

    6) ADB (Android Debug Bridge) Drivers - If not installed: http://developer.android.com/sdk/index.html

    Enable USB Debugg: Settings \ Developer options \ USB debugging (to activate them go to Settings-> About phone-> Software Information-> click many times on the Build number).

    Before proceeding further, I suggest to temporarily remove all security protocols such as pin, lock screen with a sequence or other method and scanning fingerprints. In order to avoid the forced backup password.
    I also suggest to make the extension of the files, visible (on windows, go to Tools-> Folder Options-> View-> uncheck "Hide extensions for known files").


    First phase: decrypt

    Extract the "WhatsAppKeyExtract.zip" program in a PC folder, making sure to maintain the folder structure.

    a) Start "WhatsAppKeyExtract.bat"

    b) Once started, connect your phone via USB, unlock the screen.

    c) Wait until the screen that tells you to back up your data appears.

    d) Leave the password field blank and click "Back up my data".

    e) When finished, inside the "extracted" folder (located inside the WhatsAppKeyExtractor folder) you will find the files "whatsapp.key", "msgstore.db" and "wa.db". (That's if the latest versions of whatsapp).

    At this point I recommend to save these files in a folder, calling it "new backup."

    Now we must do the same process with the old backup, then:

    Uninstall Whatsapp.

    Remove all backups from the folder Whatsapp\databases (inside the phone).

    Put back in the old backup file ( "msgstore").

    Reinstall whatsapp, and let it reopen old messages (restore backup). When done, remove the connection data from the phone (both wifi, and UMTS).

    Redo the same procedure as before, from point a) to e).

    Save these new files "msgstore.db" and "wa.db" in a folder, this time calling it "old backup."

    The first part is finished.

    Second phase: organizing the chat

    Before you start, create backup copies of previously decrypted file (you never know).

    Open SQLiteBrowsers, position yourself in BrowseData tab and select Open Database. Choose the old backup file msgstore.db (that previously we have decrypted).

    Click the lower Tab, select "messages".

    With the scroll menu, go down to the last message. Here, count the "_id" number of the last message, for example "65422"

    Open the new backup file (the new msgstore.db we had decrypted) always with the SQLite Database Browser program. By the same process: open the inferior tab and select messages. Highlight entirely the first line that has the fields, for the most part, containing the value "-1", and delete the line with the Delete Record command.

    Make a note now of the number of the first message, under "_id" for example "12"

    Now go in the tab "Execute SQL" and write the following string: UPDATE messages Set_id = (65422 + 1 + _id - 12) (put the numbers that you had marked earlier, in this case 65422 and 12). Click ExecuteSQL ( "Play" button)

    Close SQLiteBrowers.

    End of the second phase.

    Third phase: merge

    Create a new folder on your desktop called "merge".

    Rename the old backup file (the msgstore.db file that is inside the "old backup" folder) that we had decrypted, in old (so we have the file old.db).

    Rename the new backup file (the msgstore.db file that is inside the "new backup" folder) that we had decrypted and on which we had executed the SQLiteBrowser string, in new (so we have the file new.db).

    Copy and paste the two files in the directory "merge".

    Copy merjapp (merjapp.jar) in the "merge" folder.

    Now run the command prompt as an administrator.

    Enter the following commands:

    cd C: \ Users \ [username] (press "ENTER")

    cd desktop (press "ENTER")

    cd merge (press "ENTER")

    java.exe -jar merjapp.jar-old old.db -new new.db (press "ENTER")

    It must appear "Done!"

    At this point in the "merge" folder there must be a file called output (output.db file)

    Copy it in desktop and rename it msgstore (so we have the msgstore.db file).

    Open the phone's internal memory, go into WhatsApp \ Database folder, and delete all the files that are in there.

    Copy "msgstore" (the msgstore.db file that was named output) in the folder Whatsapp \ Database.

    Uninstall and reinstall WhatsApp (obviously choosing to restore backups).

    END
    5
    I spent 2 or 3 days working on merging 2 database so I just wanted to explain my steps for whoever needs it. Page 8 has a lot of great info honestly.

    What I had:
    - my historical database linked to phone number 1
    - a new database linked to phone number 2 - created as I was temporarily unable to access my phone number 1

    Goal: merge both database into one and linked to my phone number 1

    I initially assumed that I had to make a copy of all WhatsApp data in my phone 1 and then on my phone 2 switch number back to 1 so that the database would be mergeable. However, after spending quite some time looking at the architecture of the database it seems this is totally unnecessary and makes the process longer as I did countess recovery of either database (and you wait longer and longer for the verification code from WhatsApp). What identifies you in the database and more specifically in the 'messages' table is the column 'key_from_me' where 1 means you sent the message. The column that identifies in which group chat or single person chat the message belongs to is 'key_remote_jid'.

    Anyway so if you have 2 phone with 2 DB you want to merge here is how to do it (repeat on each phone)
    0) Make sure you run WhatsApp with the same version on each phone so that the database architecture is the same
    1) WhatsApp => Settings => Chats => Chat backup; set backup to Google Drive to Never then click on Back up
    This will make a local backup
    2) Find your local backup. Before Android 11 the backup is located in your Home directory / WhatsApp. Since Android 11 it is located in HOME/Android/media/com.whatsapp/WhatApp
    3) Check in WhatsApp/Databases that you have msgstore.db.crypt14 (or cryptXY depending on your version of whatsapp)
    4) Save the WhatsApp directory somewhere safe in case of accident (safe means on your computer NOT YOUR PHONE)
    if you miss this step and then lose all your data do not come crying.


    5) Uninstall WhatsApp and do not check the keep data checkbox. The data they talk about here is stored in the internal SQLite database of the app, you do not have access to it and you cannot keep this DB as it will conflict in the next steps.
    6) Install a whatsapp mod. I tried all 3 from this webpage but only Fouad WA ended up working for me.
    7) if you have Android 11 or above Move your WhatsApp folder in the Home directory (that's where the moded app looks for its data)
    8) Launch the mod, verify your phone number, then whatsapp should see you have a backup and ask you if you want to restore it. Do that
    9) Once your WhatsApp data is restored
    Click on the 3 dots on the top right corner
    Pick FMMods -> Universal -> Backup and restore -> Backup WhatsApp Data
    this backup is saved in HOME/WhatsApp/yoBackup/com.whatsapp
    10) Check in HOME/WhatsApp/yoBackup/com.whatsapp/databases that you msgstore.db This is your database decrypted!
    11) Copy that yoBackup on your computer

    Now to merge the database. I tried using the jar mentioned in page 1 but it failed to run on my computer I was getting the error "java.lang.SecurityException: Prohibited package name: java.sql". So I recompiled the code and got it to run but it would fail to merge the database, checked the result and it really didn't merge any texts. In the end I manually did it.

    12) Install DB Browser for SQLite
    13) Run the app, Open Database and pick your yoBackup/com.whatsapp/databases/msgstore.db file
    14) Click on Browse Data then pick the table 'messages' in the dropdown on the left
    Only on one of your 2 DBs :
    15) Remove the duplicate messages (select rows and click on the icon 'Delete the current record')
    16) Copy either all the rows or go block by block and then Right click on the selection => Copy as SQL

    17) Go to other DB, switch from Browse Data to Execute SQL
    18) Paste the content - you should have something like
    INSERT INTO "main"."messages" ("_id", "key_remote_jid", "key_from_me", "key_id", "status", .... many more tables)
    VALUES ('10', '10000000000@s.whatsapp.net', ..... many values)
    18) Click on the Execute All button. If this failed it means you are trying to insert rows that already exists, so you need to go back to step 15 and remove those duplicates.
    After this step you have merge all your messages in one DB, so you can save your changes and close the database.

    So now one of your two yoBackup folder should have a msgstore.db with all your messages.

    19) Copy this file back to the yoBackup directory on the phone where you want to recover all your messages (replace the smaller msgstore.db)
    20) Uninstall, Reinstall the moded WhatsApp (or go to your android settings => Application, find your app, Storage, Clear Storage)
    21) Launch the app and click on the restore button (before verifying your phone number; the mod looks for yoBackup and then restore the info in it)
    22) Complete the rest of the WhatsApp setup
    23) Now all your messages are in one database !

    If you want to run the official WhatsApp app keep going:

    24) make a local backup (see step 1); check for a backup saved in HOME/WhatsApp/Databases ==> This creates an encrypted database that we can restore in the official app !
    25) Uninstall the mod and install WhatsApp (official)
    26) Move the WhatsApp folder back to its original location (undo step 7)
    27) Launch WhatsApp, verify your number and if the application detects a backup restore it and you're DONE !!!

    Restoring the encrypted merged DB in the official time took me a day!! It seems like it wasn't recognized it as a legit DB and thus wouldn't let me restore it. To trick WhatsApp into restoring it I did the following.
    28) Wipe WhatsApp internal storage one more time (like in step 20)
    29) Move your encrypted database away from WhatsApp folder (move msgstore.db.crypt14 to your download folder for instance)
    30) Copy either of the backup you made in step 1 (those backups were made with untampered data and official app) and place it in the WhatsApp/Databases folder
    31) Launch again the app, verify your number and now you shoud see WhatsApp telling you it found a backup to restore!
    32) Do not click on restore, instead go back to your File manager and remove the database you copied in step 30 and undo step29, place it back to the databases folder!
    33) Go back to WhatsApp and now when you will click on restore the backup it will restore it !!

    DONE
    Thanks to all of those who posted before me, I couldn't have made it without y'all :)
    maybe I'll do a video to explain all that 😅
    2
    Okay guys so i backup my whatsapp chat history last week before i uninstall it BUT whatsapp gave me a corrupted backup (wtf man) and i couldnt restore the chats upon reinstall.
    After trying for around 6 days, i have finally restored my chats with the help of various professionals in this thread and other threads across XDA

    Putting this here incase someone had the same issue of corrupted chats.
    1) I logged in to my whatsapp on a rooted emulator on PC to obtain my decryption key because i have no intention in rooting my phone and my phone is on Android 11 which means most methods to obtain key without root wont work

    2) i copied out the key from the emulator and use it to decrypt my corrupted whatsapp backup and my old whatsapp backup that i stored on my PC (using Whatsapp Viewer and the APK version of WhatsCrypt)

    3) i used the following command with sqlite3 installed to recover the corrupted chat backup so SQL browser can read it (although whatsapp still WONT restore it no matter what and how)
    sqlite3 broken.db ".recover" | sqlite3 new.db
    ^ remember to rename "broken.db" to your chat backup .db filename

    4) i used the instruction by OP (post #1) to delete the duplicated chats in my new corrupted backup and merged it with the merjapp.jar method with my old backup (that is working)

    5) i copied the msgstore.db to YoWhatsapp/database folder to restore it (Official whatsapp blocked restoring of unencrypted msgstore.db already, can only restore with ROOT or modded whatsapp)

    6) i verified my number and restored my backup (the merged unencrypted msgstore.db) and all my chats are in there!

    NOTE: with this method, your main chat screen will still show only chats of your OLD backup for each contact. But when you press inside, you can see all the new merged chats. I think this is because there are other tables in the SQLDB that need to update for it to reflect the new chats on main page but I can live with this.

    7) i create an encrypted backup in yowhatsapp and i will restore it to the official whatsapp client after a few days (cause of the sms block due to keep trying to restore backup)

    I have spent ard 6 days to read through countless of threads and had finally came up with a solution! Cheers!
    I hope and believe that this post will definitely help people moving forward as whatsapp backup sucks.
    Next time please remember to backup 5 files to prevent whatsapp giving u a corrupted backup and screw you up again!
    2
    Guys, I have FINALLY found a way to merge two differten WhatsApp backup files. I'll post the guide asap (have to translate it). Is different from the one on the first page for the first two parts.

    Many thanks for finding the time to post your updated working method. I'm sure your contribution will come in handy for many users. :)