mongodb 导出操作
- 我的是备份数据库,链接到数据库服务器来备份的
终端shell命令实现
远程连接服务器:
mongo -host 10.202.***.** -port 27017 --authenticationDatabase xz**
导出远程服务器到本地:
mongodump -host 10.202.***.** -port 27017 --authenticationDatabase=xz** -o /data/
./mongodump -h 10.202.***.** : 27017 --authenticationDatabase admin -d xz** -o /data/
我的不用用户名登录的备份命令
mongodump -h 10.202.***.** : 27017 -d xz** -o /data/
shell 脚本实现
find -type -d ------>d 目录
find -type -f------->f 一般文件
加上定时器,定时执行
我的mac恢复备份数据命令
-
mongorestore -h 127.0.0.1:27017 -d xzsp --dir ~/Downloads/xzsp/xzsp
-
shell find 参数详解:https://www.runoob.com/linux/linux-comm-find.html
相信坚持的力量,日复一日的习惯.