CodeBrauer
CodeBrauer

Reputation: 2925

Restore corrupt mongo db from WiredTiger files

So here is my scenario:


> show dbs
local  0.000GB
> use wekan
switched to db wekan
> show collections
> db.users.find();
>

Also I already tried db.repairDatabase();, no effect.

Now my _data directory contains a lot of *.wt files and more. (File list)

I found collection-0-2713973085537274806.wt which has a file size about 390MiB.

This could be the data I need to restore, assuming its size.

Any way of restoring this data?

I already tried my luck using wt salvage according to this article, but I can't get it running - still trying.

I know backups,backups,backups! Sadly this database wasn't backuped.

Related GitHub issue, contains details to software.


Update:

I was able to create a .dump file with the WiredTiger Data Engine tool. However I can't get it imported into a mongoDB.

Upvotes: 1

Views: 2887

Answers (1)

Amir Rajak
Amir Rajak

Reputation: 31

Try running a repair on the mongo db container. It should repair your database and the data should be completely restored.

Start mongo container in bash mode.

sudo docker-compose -f docker-compose.yml run mongo bash

or

docker run -it mongo bash

Once you are inside the docker container, run mongo db repair.

mongod --dbpath /data/db --repair

The DB should repaired successfully and all your data should be restored.

Upvotes: 2

Related Questions