You suddenly realize that you cannot find a few records in your production MongoDB & you want to restore them
The pattern assumes that you know which records to restore ie you know couple of unique field values in the lost records
Our use case : In our system we have lots of interesting Fact Tables & System Collections. While these collections are small they are very complex & strategic to the application (the why is a topic for another day, another pattern). And we know how many records are there in these collections.
Few days ago we realized that we have only 12 records in one of our system collection; it should have 13. We know which record is missing, but it is not easy to recreate.
Luckily I have been backing up the database regularly.
So, the mission if I choose to accept, is to find the 13th record from the latest backup that contains it and restore the record to our prod database
As we are storing data in json format, this will not work if we have blobs
This creates a snapshot under the <dump> directory. I usually rename it as mongodump2012-MM-DD
Start a local instance on mongo – mongod
Restore the database from the last backup (for example mongodump-2012-08-21) locally
Check to see if the missing record is in this backup and find the _id of the record using command line. If not try the next to last backup – for example mongodump-2012-08-17. (In our case, I found it in the next to last)