当前位置:Gxlcms > 数据库问题 > MongoDB备份与还原

MongoDB备份与还原

时间:2021-07-01 10:21:17 帮助过:10人阅读

还原方法:
mongorestore -h <hostname><:port> -d dbname <path>

备份正常,但还原出现报错:

Failed: blog.posts: error restoring from w/posts.bson: reading bson input: invalid BSONSize: 1802661751 bytes

网上查找资料说加上参数--batchSize=10,但还是不行。

最后在MongoDB官方网站找到了解决方法:备份时使用导出归档文件形式,还原也使用归档文件形式。

备份:
mongodump --archive=test.20150715.archive --db test
还原:
mongorestore --archive=test.20150715.archive --db test

注意以上方法适合MongoDB 3.2版本以上。

MongoDB备份与还原

标签:out   htm   top   ocs   mongo   failed   attribute   code   dbn   

人气教程排行