MongoDB Dump and Restore a Database

MD
R
Markdown

Simple receipt with the commands used to Dump and sequentially Restore a MongoDB Cluster

Step by Step Instructions

Assuming in you are ssh'ed into an ubuntu 16 based machine

  1. Dump the Source Database into a folder called source-db-dump mongodump --host my-source-db.mongodbdns.com --port 27000 --username joao --password xpto --authenticationDatabase devops --db core --out /source-db-dump/

  2. Now restore the core db from the dummped folder source-db-dump mongorestore --host my-destination-db.mongodbdns.com --port 27000 --username joao --password xpto --authenticationDatabase devops --db core --out /home/ubuntu/source-db-dump/core

  3. You can restore to other destinations also (eg. Atlas), core db from the dummped folder source-db-dump mongorestore --host my-atlas-shard-0/my-atlas-shard-00-00-qruor.gcp.mongodb.net:27017,my-atlas-shard-00-01-qruor.gcp.mongodb.net:27017,my-atlas-shard-00-02-qruor.gcp.mongodb.net:27017 --ssl --username joao --password xpto --authenticationDatabase admin -d core /home/ubuntu/7dec/source-db-dump

Created on 2/25/2019