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/


官方文档

猜你喜欢

转载自www.cnblogs.com/brainworld/p/9156680.html