Hi @bp_sin
I would be very cautious in your scenario. I strongly recommend you take a backup of your production database and test all outcomes in a separate environment first. If this is critical production data to restore and your team doesn’t have the in-house expertise, I would consider hiring a consultant for assistance.
If I understand your situation correctly:
- Some data before July 13th was accidentally deleted
- You have a file copy backup of the
dbPath
before the data was deleted - You want to merge missing data into a production database
The last step is the most complicated: unless collections of interest happen to be insert only, there may be conflicts between the current data and the data as of a month ago. You will have to work out how to reconcile any differences. Restoring older data will also include data that has been intentionally removed at a later date.
My suggested approach would be:
- Start a
mongod
in a test environment using the dbPath backup from July 13th. Verify that this is a viable backup and the data that you are looking for is available. - Take a backup of your production data and restore into a separate
mongod
in a test environment. - Write queries (or a script) to compare collections of interest in these two test environments.
- Use
mongodump --query
to selectively export missing data from the July 13th backup. - Import into your production test server using
mongorestore
, and verify the outcomes are as you expect. - Repeat in production once you are confident your procedure results in the desired outcome. Always take fresh backups before doing any maintenance procedures that might alter data.
Unless your production data is not essential, I would take the time to set up a test environment.
Regards,
Stennie