您的位置:首页 > 数据库 > Mongodb

mongoDB备份与恢复

2017-08-27 18:40 246 查看
同事整理的命令,经常用到拿过来记录一下。

备份

mongodump --host dds-m5b42.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p [password] -d [db] -o /www/db


恢复

mongorestore --host dds-mb42.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p [password] -d [db] /www/db/game_center


备份Collection

mongodump --host dds-m842.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p [password] -d [db] -c [collection] -o /www/db


恢复Collection

mongorestore --host dds-m511b.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u root -p [password] -d [db] -c [collection] /www/db/game_center/[collection.bson]


参数

-h or --host: mongodb    // mongo连接地址
-u: username             // 用户名
-p: password             // 密码
-d: database             // 要备份的数据库 或 要恢复的数据库名称
-c: collection         // 要备份的collection 或 要恢复的collection
-o: savepath            // 备份数据保存位置
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mongodb