Skip to content

Instantly share code, notes, and snippets.

@MostafaEzzelden
Forked from saggiyogesh/mongo_dump_restore.md
Last active May 16, 2020 17:49
Show Gist options
  • Save MostafaEzzelden/bd03294dd998f4667fcac4e1a9e889af to your computer and use it in GitHub Desktop.
Save MostafaEzzelden/bd03294dd998f4667fcac4e1a9e889af to your computer and use it in GitHub Desktop.
Mongodb dump and restore from mlab
  • install mongodb on local machine (mongodump & mongorestore) commands are required.
  • command dumping. to dump locally

mongodump -d dbname -o dumpname -u username -p password

  • command dumping to dump mlab database

mongodump -h xxx11.mlab.com:11 -u user -p password --authenticationDatabase release-db -d release-db -o /home/dumps

**Options** `-h`: mlab host:port, `-u`: db user, `-p`: db user password, `--authenticationDatabase` `-d`: mlab dbname, `-o`: path to store backupfiles
  • restore command, to restore locally

    mongorestore --db dname /home/dumps

    Otherwise to restore in mlab, create a new db and replace the options

    mongorestore -h xxx22.mlab.com:22 -u admin -p password --authenticationDatabase release-backup -d release-backup /home/dumps/

🐫 💥

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