If somebody accidentally dropped a MongoDB database but executing db.dropDatabase(), how can he recover the database?
Dropping a database in MongoDB is simple, and the command db.dropDatabase() won't erase all the data on it but marks it as to be deleted, so the size of the database would not change after using the drop command, which I think there should be some way to remove the to-be-deleted marker. Can some one point me how?
I tried to reproduce what you had done. I killed a database using db.dropDatabase() after I had backed it up :-) The db name was 'gacheater'. Before dropping mongodb folder contained 3 files (the db is non-empty):
after dropping these files disappeared. Therefore I think mongodb really removes your data.
So the only choice you have is to try to restore files from the filesystem
PS: MacOS 10.5, MongoDB 1.8.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With