MongoDB

Backing up and Restoring Data

Basic mongodump of local default mongod instance

mongodump --db mydb --gzip --out "mydb.dump.$(date +%F_%R)"

This command will dump a bson gzipped archive of your local mongod ‘mydb’ database to the ‘mydb.dump.{timestamp}’ directory

Basic mongorestore of local default mongod dump

mongorestore --db mydb mydb.dump.2016-08-27_12:44/mydb --drop --gzip

This command will first drop your current ‘mydb’ database and then restore your gzipped bson dump from the ‘mydb mydb.dump.2016-08-27_12:44/mydb’ archive dump file.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow