mongodb 备份数据

2019-08-15  本文已影响0人  赵荆州

备份[部分]数据为dump,然后从collection中将已备份数据删除。

./mongodump  -d trans -c test -h 192.168.190.128 -u trans -p 123456 -o /data/backup

-h:指明数据库宿主机的IP

-u:指明数据库的用户名

-p:指明数据库的密码

-d:指明数据库的名字

-c:指明collection的名字

-o:指明到要导出的文件名

-q:指明导出数据的过滤条件

恢复备份的数据

./bin/mongorestore -h host -d test --drop data/backup/test/

-h:指明数据库宿主机的IP

-u:指明数据库的用户名

-p:指明数据库的密码

-d:指明数据库的名字

--drop 为先删除collection中的数据再恢复

上一篇 下一篇

猜你喜欢

热点阅读