Recover MongoDB data without WiredTiger.wt file

1,648 views
Skip to first unread message

Mohammad

unread,
Aug 11, 2017, 12:44:45 PM8/11/17
to mongodb-user

We have recovered a MongoDB database from filesystem, but the WiredTiger.wt file has changed since then (i.e. the collection has been dropped).


So is it possible to read data (documents) from some .wt files without having the corresponding WiredTiger.wt?


Or create a WiredTiger.wt file with our own .wt files?


I have also asked this question on StackExchange:

http://dba.stackexchange.com/questions/183267/recover-mongodb-data-without-wiredtiger-wt-file

Rhys Campbell

unread,
Aug 13, 2017, 12:38:23 PM8/13/17
to mongodb-user
If you have no backup to recover from I suppose you might be able to recreate the collections / metadata on another mongo instance and then use the generated WiredTiger.wt after editing it. This has a whole load of quite specific metadata inside it, like lsn numbers and collection data and index filenames. All of these would have to match to work. Perhaps this is feasible if you have a small number of collections / indexes but I would imagine you're out of luck unless you have many, many days to work on this.

Mohammad

unread,
Aug 16, 2017, 1:06:38 AM8/16/17
to mongodb-user
How can I edit WiredTiger.wt file.

Is there a documentation for WiredTiger.wt structure and format?

Rhys Campbell

unread,
Aug 16, 2017, 4:24:39 AM8/16/17
to mongodb-user
Perhaps you can find something useful here...


I would imagine this being a mammoth task.

Kevin Adistambha

unread,
Aug 17, 2017, 7:01:07 PM8/17/17
to mongodb-user

Hi Mohammad

We have recovered a MongoDB database from filesystem, but the WiredTiger.wt file has changed since then (i.e. the collection has been dropped).

Could you elaborate on what you did? Did you perform the recovery by overwriting some collection-*.wt files inside your dbpath?

If that is the case, then your database is in an unsupported state, and it’s likely that you lost your data. If you want to restore the database, you would need to restore the dbpath as a whole and not as individual files. Please see MongoDB Backup Methods for instructions and information on supported backup and restore methods.

The WiredTiger.wt file is a crucial metadata file that keeps track of the state of the whole database and all the *.wt files. Hence, the content of this file is deployment specific, and not transferrable to other deployments. It is not possible to recreate the content of this file.

If you have a known good backup of the whole dbpath, you may be able to restore to a valid state of the database, as long as you restore the dbpath as a whole.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages