ubuntu mongodb backup/restore (备份和恢复)

备份(导出)

1.导出单个collection-.json格式

mongoexport --host:127.0.0.1 --port:27017 --db test --collection testcollection --out /xxx/testcollection.json
2.导出整个db的数据 --host 默认为127.0.0.1 --port 默认为27017

mongoexport --db test --out /xxx/
会生成一个dump文件夹


恢复

mongorestore --db accounts dump/


官方文档

posted @ 2018-06-08 17:16  善未易明  阅读(177)  评论(0编辑  收藏  举报