Restore deleted MongoDB documents
Overview​
In some cases we may need to recover one or more documents that were hard-deleted from a production MongoDB cluster. When that happens, we can use the automatic periodic cloud backups of all production DBs to restore the deleted documents. All production DBs take a snapshot of their contents every 6 hours, which should suffice for recovering from most accidental data deletion issues.
The high-level process is to restore a DB snapshot to a new temporary cluster, copy the documents from there and insert them to the source cluster.
Never restore a snapshot directly to the source cluster, as that will cause all data changes since the snapshot was taken to be lost forever.
Before you begin​
Collect the following information:
- The relevant production cluster (which region).
- The approximate time of deletion.
- The collection name and a stable identifier for every deleted document, to be able to reliably find them in the DB.
Restore and recover the documents​
1. Select a snapshot from before the deletion​
- Open the correct project in MongoDB Atlas.
- In the sidebar, go to Database > Backup.
- Find the newest successful snapshot whose timestamp is before the deletion.
Carefully confirm the snapshot timestamp against the data deletion time (and take time zones into account) before continuing to ensure the right snapshot is chosen. Note down the timestamp of the snapshot.
2. Create an empty temporary cluster​
In the sidebar, go to Database > Clusters and keep the page open to be able to reference the cluster's details. In another tab open the same page and click 'Create' and then 'Go to Advanced Configuration'. Proceed to create a new dedicated cluster with the following settings:
- Give the cluster a name that clearly identifies its purpose, for example:
restore-backend-us-east-2-2026-07-20 - Match the source cluster's cloud provider, region and tier
- Choose the same MongoDB major version as the source cluster
- Set a storage size that is large enough to hold the restored snapshot, based on the storage size of the source cluster
- Disable cloud backup for the new cluster
Go back to the Database > Clusters page and wait until the new cluster is fully available before continuing. This can take up to 10 minutes.
3. Restore the snapshot to the temporary cluster​
- Return to the production cluster's backup details.
- Locate the snapshot selected in step 1 and click Restore.
- You can choose specific collections to restore, or restore the whole database
- Verify the right project is selected as the Destination Project
- Make sure to choose the new cluster as the 'Destination Cluster'!
- Start the restore.
You will be automatically navigated to Database > Backup > Restores which will show the status of the restore job. Wait until the job reports that it completed successfully for the temporary cluster before continuing.
If the temporary target cluster was created with wrong configuration which don't match the source cluster the restore operation may fail and show the specific error that occurred. If that happens delete the temporary cluster and go over the steps again.
4. Find and copy the deleted documents​
- Open Data Explorer for the temporary cluster.
- Open the relevant collection
- Query by the stable identifier of the deleted documents to find them, like customer id + document id.
- Confirm that the result is the intended document and represents its expected state before deletion.
- Copy the document
- Open the same collection in the production cluster's data explorer and insert the copied document. Make sure to insert the full copied document (including the
_idfield).
Repeat these steps for every affected collection and related document.
5. Clean up​
After all documents were restored and the recovery has been verified:
- Go to Database > Clusters page
- Terminate the temporary cluster
Recovering a larger set of documents​
Manual copying is intended for a small, well-defined set of documents. For a larger recovery, there are more automated options that can be used:
- MongoDB Compass: Apply a filter on the temporary cluster, export only the query results as Extended JSON, and import them into the matching production collection. Use an Extended JSON format that preserves BSON types; do not use CSV. See Import and Export Data in Compass.
- MongoDB Database Tools: Use
mongodumpwith a collection and query filter against the temporary cluster, then usemongorestoreto insert that BSON data into the intended production namespace. Review duplicate-key behavior and test the exact commands outside production first. See themongodumpandmongorestoredocumentation.