Backup
-d Specifies the database to be backed up,-o Specifies the backup location,
bin>mongodump-d test-o Backup//(backup is the back up directory, created to the bin directory by default)
Recovery
-d Specifies the database to revert to, which restores the backed-up database to a database that does not have the same name as the original, where mongodb2,--drop means to delete the collection (if any) before recovery. Otherwise, the data is merged with the existing collection data and may overwrite some documents.
bin>mongorestore-d Test--drop backup/test/
Inserting test data
> Db.test.save ({123: ' abc '})
> Db.test.find ();
#查看所有数据库
Show DBS
#查看主从复制状态
Db.printreplicationinfo ()
#修复数据库
Db.repairdatabase ()
This article is from the "XFICC" blog, make sure to keep this source http://xficc.blog.51cto.com/1189288/1564655
MongoDB Backup and Recovery