A small utility that can be used to merge multiple WhatsApp databases (
msgstore.db) into one.
A few notes:
- input databases must be already decrypted
- output database will also be in decrypted form.
To use it, it must either be moved to
/data/data/com.whatsapp/databaseson a rooted phone,
or otherwise encrypted again and restored as usual.
- Java 11 is required to run the program.
- this is a JVM tool that must be compiled. You can just
./gradlew buildor use the IntelliJ run
configuration that is checked into source code.
- The only argument required is a path to a directory on your local machine. For example,
mydiris specified, the program expects all input databases in
mydir/inputand will create
How it works
The program is inspired by whapa. WhatsApp msgstore.db is just a SQLite database
and as such it can be read and written to with common tools.
The program will merge all relevant tables, not just messages and chats. See
src/main/kotlin/dev/natario/Table for a list.
When merging them, extra care is taken:
- primary keys, when possible, are given the appropriate offset in order to not collide with existing entries in the other
- When this happens, we also apply the same offset in every other column of the database that were
referencing them, ensuring consistency of data.
messages._id will receive an offset to avoid collision, then the program will also
modify all other columns pointing to messages, like for example
The tool can have troubles with binary data, especially in the
message_thumbnails table. If the data contains many null bytes (
the SQL string will include many concatenations (like
'foo'||char(0)||'bar') and there is a hard limit in the driver about
how many concatenation operations it can handle for a single statement.
By default, the merger will simply drop thumbnails that it was not able to copy.
It doesn’t work for me!
I’m sorry. This happened to work for me in March 2022, but I am unlikely to spend time on this utility in the future,
especially since the database schema can change over time. However, I am happy to review and accept pull requests.
The source code should be very easy to understand.