Skip to main content

Dump and Restore Database

Linux​

Dump​

DB_NAME=foo
mongodump --db=$DB_NAME --out=./

Restore​

mongorestore --drop --db=$DB_NAME mongo_dump/$DB_NAME/

Windows​

Dump​

"c:\program files\mongodb\mongodump.exe" --host=localhost --port=27017 -u $USER -p $PASS /d $DB_NAME /authDB $ADMIN

Restore​

"c:\program files\mongodb\mongorestore.exe" --host=localhost --port=27017 -u $USER -p $PASS /d $DB_NAME /authDB $ADMIN /dir {path/to/dump} /drop