MongoDB备份恢复

备份(mongodump):

备份单个表
mongodump -u  root -p 123456  --port 27017 --authenticationDatabase admin -d bill -c d -o /root/mongodb/bill_d_bak_201507021701.bak
备份单个库
mongodump  -u  root -p 123456 --port 27017  --authenticationDatabase admin -d bill -o  /root/mongodb/
备份所有库
mongodump  -u  root -p 123456 --authenticationDatabase admin  --port 27017 -o /root/bak 

恢复(mongostore)

恢复单表
mongorestore -u  root -p 123456  --authenticationDatabase admin -d bill -c d /root/mongodb/bill_d_bak_201507021701.bak/bill/d.bson
恢复单库
mongorestore  -u  sroot -p 123456 --port 27017  --authenticationDatabase admin -d bill   /root/mongodb/
恢复所有库
mongorestore   -u  root -p 123456 --port 27017  --authenticationDatabase admin  /root/bak

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code