How to restore a single collection from a MongoDB Atlas Snapshot

How can I restore a single collection from a MongoDB online Snapshot?

I have tried downloading the snapshot and copying it over the local Docker data folder of MongoDB. It does start but then I am no longer able to login using either the old root user password, or any of the users in the MongoDB Atlas database.

I need to be able to restore just a single collection from one of the backups from a point in time. I know if I make an archive using mongodump, I can restore it locally with mongorestore. However, mongorestore doesn’t let me specify the downloaded gz file. It reports it is in an incorrect format.

I have deleted the contents of a collection by accident, and just need to get that data back either using the online UI or a local docker copy.


To restore a single collection from an online MongoDB snapshot, you can use the following steps:

  1. Download the snapshot that you need to restore.
  2. Create a new MongoDB instance.
  3. Restore the snapshot to the new MongoDB instance using the mongorestore command and specify the path to the snapshot:
mongorestore --host <hostname> --port <port> --username <username> --password <password> --db <database> --collection <collection> <path-to-snapshot>

  1. Once the restore is complete, you can copy the single collection to your original MongoDB instance using the mongoexport and mongoimport commands:
mongoexport --host <new-instance-hostname> --port <new-instance-port> --username <new-instance-username> --password <new-instance-password> --db <new-instance-database> --collection <collection> --out <collection>.json

mongoimport --host <original-instance-hostname> --port <original-instance-port> --username <original-instance-username> --password <original-instance-password> --db <original-instance-database> --collection <collection> --drop --file <collection>.json

This way, you can restore a single collection from a MongoDB online snapshot without affecting the rest of the data in your original instance.

1 Like

Hi. I have a serverless instance and according to the documentation, I cannot download a snapshot from a serverless instance. I too need to restore just a collection not the entire cluster. Is there any way to do this with a serverless instance?