diggzhang
diggzhang

Reputation: 547

How to restore Mongo(WT engine) only with collection-0-****.wt file?

My mongodb can't lanuch now, when I want start mongo got error ***aborting after invariant() failure

Now I want to restore collection-0-****.wt file to a new db, is this possible?

Upvotes: 9

Views: 18245

Answers (2)

Kartik Narang
Kartik Narang

Reputation: 201

I had the same issue and after spending 5 hours doing everything, found this. https://medium.com/@imunscarred/repairing-mongodb-when-wiredtiger-wt-file-is-corrupted-9405978751b5

You will need to restore 1 collection at a time(a few at once when you get the hang of it), but it works!

Upvotes: 0

Stennie
Stennie

Reputation: 65403

As at MongoDB 3.2, only full backups of WiredTiger data directories can be copied into a new instance. WiredTiger collection or index files aren't self-contained; they rely on other metadata in the WiredTiger.* catalog files. The invariant/assertion you are getting on startup is expected if data files are incomplete or inconsistent.

If you want to backup and restore a single collection, you should use mongodump and mongorestore, eg:

 mongodump --db test --collection northwind --host host1

 mongorestore --db test dump/test/northwind.bson --host host2

For supported full backup procedures, see: MongoDB Backup Methods.

Upvotes: 1

Related Questions