{"id":18465138,"url":"https://github.com/natario1/whatsapp-database-merger","last_synced_at":"2025-04-08T08:31:42.244Z","repository":{"id":99104672,"uuid":"466563965","full_name":"natario1/whatsapp-database-merger","owner":"natario1","description":"Small command-line utility to safely merge multiple WhatsApp backups (msgstore.db) into one.","archived":false,"fork":false,"pushed_at":"2022-11-25T07:19:19.000Z","size":76,"stargazers_count":71,"open_issues_count":6,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-23T09:24:01.650Z","etag":null,"topics":["backup","database","kotlin","whatsapp","whatsapp-backup"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/natario1.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-03-05T20:45:42.000Z","updated_at":"2025-03-02T04:36:04.000Z","dependencies_parsed_at":"2023-06-03T20:45:25.985Z","dependency_job_id":null,"html_url":"https://github.com/natario1/whatsapp-database-merger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natario1%2Fwhatsapp-database-merger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natario1%2Fwhatsapp-database-merger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natario1%2Fwhatsapp-database-merger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natario1%2Fwhatsapp-database-merger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natario1","download_url":"https://codeload.github.com/natario1/whatsapp-database-merger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247804517,"owners_count":20999002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","database","kotlin","whatsapp","whatsapp-backup"],"created_at":"2024-11-06T09:12:05.525Z","updated_at":"2025-04-08T08:31:41.935Z","avatar_url":"https://github.com/natario1.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# whatsapp-database-merger\n\nA small command-line utility that can be used to merge multiple WhatsApp databases (`msgstore.db`) into one.\nA few notes:\n- input databases must be already decrypted\n- output database will also be in decrypted form. To use it, it must either be moved to `/data/data/com.whatsapp/databases` on a rooted phone,\n  or otherwise encrypted again and restored as usual.\n- Java 11 should be installed to build and run the program.\n\n### Usage\n\nYou can either build the tool yourself or download the binary from the [releases page](https://github.com/natario1/whatsapp-database-merger/releases).\nThe tool requires a single argument - a path to a directory on your local machine. For example:\n\n```\n./whatsapp-database-merger /Users/Me/Desktop/WhatsApp\n```\n\nIn this example, the program will look for input databases in the `/Users/Me/Desktop/WhatsApp/input` folder, \nand will create the merged database in `/Users/Me/Desktop/WhatsApp/output`.\n\n### How it works\n\nThe program is inspired by [whapa](https://github.com/B16f00t/whapa). WhatsApp msgstore.db is just a SQLite database\nand as such it can be read and written to with common tools.\n\nThe program will merge all relevant tables, not just messages and chats. See `src/main/kotlin/dev/natario/Table` for a list.\n\nWhen merging them, extra care is taken:\n- primary keys, when possible, are given the appropriate offset in order to not collide with existing entries in the other\n  database(s).\n- When this happens, we also apply the same offset in every other column of the database that were referencing them, \n  ensuring consistency of data.\n- Special logic addresses the case where entries could not be inserted due to unique constraint defined in the database,\n  in which case all references to the skipped entry will be updated to match the existing entry which prevailed.\n\nFor example, `messages._id` will receive an offset to avoid collision, then the program will also\nmodify all other columns pointing to messages, like `chat.last_read_message_row_id`.\n\n### Known issues\n\nThe tool can have troubles with binary data, especially in the `message_thumbnails` table. If the data contains many null bytes (`\\u0000`),\nthe SQL string will include many concatenations (like `'foo'||char(0)||'bar'`) and there is a hard limit in the driver about \nhow many concatenation operations it can handle for a single statement.\n\nBy default, the merger will simply drop thumbnails that it was not able to copy.\n\n### It doesn't work for me!\n\nI'm sorry. This happened to work for me in March 2022, but I am unlikely to spend too much time on this utility in the future,\nespecially since the database schema can change very quickly. However, I am happy to review and accept pull requests. \nThe source code should be very easy to understand.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatario1%2Fwhatsapp-database-merger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatario1%2Fwhatsapp-database-merger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatario1%2Fwhatsapp-database-merger/lists"}