15

I've enabled automatic backups on Mongo Atlas. Now I need to view and query a specific snapshot to check some documents? How can I do it quickly and safely?

Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61
rzymek
  • 9,064
  • 2
  • 45
  • 59

2 Answers2

19

Go to Mongo Atlas console, click on your cluster, then go to Backup tab and download your snapshot:

enter image description here

You'll get a .tgz archive. It opens in a popup, so mind your blocker.

Unpack the archive, then run

docker run -it -p 27017:27017 -v /tmp/extracted/snapshot/dir:/data/db  mongo

Now you can connect to the snapshot data using a mongo client like MongoDB Compas using default connection (localhost:27017).

Ryan Knell
  • 6,204
  • 2
  • 40
  • 32
rzymek
  • 9,064
  • 2
  • 45
  • 59
  • 2
    On windows `//` must be used for the drive and path like ```docker run -d -p 27017:27017 -v //c/restore-5f745d065f8089221bb0c572:/data/db --name=mymongo mongo``` – krl Oct 29 '20 at 21:45
  • 2
    It works for me with the published port `-p 27017:27017` and correct version of mongo image, like `mongo:4.2.15` – sneawo Jul 21 '21 at 12:01
16

The accepted answer did not work for me. Alternative approach:

Download the backup from your Atlas console and extract it.

Then run the following in your Terminal:

mongod --dbpath ~/Downloads/Cluster0-2020-11-20T15-53-03.006Z

Replacing Cluster0... with your extracted folder.

Now you can connect to the snapshot data using a mongo client like MongoDB Compass using default connection (localhost:27017).

You can also define a custom port with --port

lukasvo
  • 3,622
  • 1
  • 15
  • 14