Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a Mongo Atlas backup snapshot locally?

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?

like image 854
rzymek Avatar asked Oct 03 '19 19:10

rzymek


People also ask

How do I restore my atlas backup locally?

Click the name of your Atlas Cluster. Click the Backup tab. Click the Restores & Downloads sub-tab. Navigate to the restore snapshot you created.

How do I query backups in MongoDB Atlas?

To get started, you can log into your MongoDB Atlas panel and the "Backup" icon on the left side of your screen. Once you've reached the backup section, you'll find an ellipsis ("...") dropdown menu with some options – select the "Query" option.


2 Answers

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).

like image 67
rzymek Avatar answered Sep 22 '22 06:09

rzymek


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

like image 28
lukasvo Avatar answered Sep 22 '22 06:09

lukasvo