How to backup and restore databases
Start Mongo, open a new tab in terminal.
First navigate to the folder where you want to save the backup, then
type the following command.
Backup single database:
mongodump --host localhost --port 27017 --db db_name
Restore single database:
mongorestore --host localhost --port 27017 --db **** dump/db_name
(In this case, ****
represents UserDefinedName for the database > mydb dump/db_name > this will import dump db into mydb)
Backup all databases:
mongodump --host localhost --port 27017
Restore all databases:
mongorestore --host localhost --port 27017 dump
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…