s7xwvg
Last Updated: February 25, 2016
·
5.721K
· hugomaiavieira
235c2eee6a3fd6bae5339a8941de07d2

Dump and restore mongo database

Dump the database:

$ docker exec -t mongo mongodump --out /data/db/backup
$ tar -zcvf backup.tar.gz /opt/{project}/mongodb/backup

Restore the database:

$ tar -zxvf backup.tar.gz
$ mongorestore opt/{project}/mongodb/backup/{database_name} -d {new_database_name}

If you whant to clean the database:

$ mongo
use {database_name};
db.dropDatabase();

http://docs.mongodb.org/manual/tutorial/backup-with-mongodump/

Say Thanks
Respond