MongoDB 备份(mongodump)与恢复(mongorestore)

备份:

mongodump -h localhost:27017 -d test -o "D:\data\db1"

还原备份:

D:\mongodb\bin>mongorestore -h localhost:27017 -d test --drop "D:\data\db1\test"

如果不加--drop 会提示错误

error: E11000 duplicate key error index: test.runoob.$_id_ dup key: { : ObjectId('5b076926d2476498526a9d3b') }

提示以前数据库中存在着与备份文件中相同_id 的数据

猜你喜欢

转载自www.cnblogs.com/zyfadmin/p/9099751.html