Skip to content

Instantly share code, notes, and snippets.

@kyrcha
Last active March 11, 2021 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyrcha/07185fdc147f6e3d358ddfcdae305813 to your computer and use it in GitHub Desktop.
Save kyrcha/07185fdc147f6e3d358ddfcdae305813 to your computer and use it in GitHub Desktop.
Bring a mongodb database from a cloud atlas cluster, locally, using two commands

Let's assume the database is named "production" in your mongodb atlas cluster. First we do a dump:

mongodump --uri="mongodb+srv://<username>:<password>@<subdomain>.mongodb.net/production" --archive="mongodump-production"

Make sure you fill in the correct:

  • username
  • password
  • subdomain

above.

And then a restore in our local mongodb installation:

mongorestore --uri="mongodb://<local-username>:<local-password>@localhost:27017" --archive="mongodump-production" --nsFrom='production.*' --nsTo='production.*'

Make sure you fill in the correct:

  • local-username
  • local-password

and that there is no database named production in your local installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment