Mongodb自动备份脚本
来源:互联网 发布:jmeter数据库查询结果 编辑:程序博客网 时间:2024/06/08 11:52
Mongodb自动备份脚本
备份
#!/bin/bashsourcepath='/data/mongo/mongodb'/bintargetpath='/data/mongo/mongobackups'nowtime=$(date +%Y%m%d)start(){ ${sourcepath}/mongodump -h 127.0.0.1:32762 -d test -o ${targetpath}/${nowtime}}execute(){ start if [ $? -eq 0 ] then echo "back successfully!" else echo "back failure!" fi}if [ ! -d "${targetpath}/${nowtime}/" ]then mkdir ${targetpath}/${nowtime}fiexecuteecho "============== back end ${nowtime} =============="
删除30天之前的备份
#!/bin/bashtargetpath='/data/mongo/mongobackups'nowtime=$(date -d '-30 days' "+%Y%m%d")if [ -d "${targetpath}/${nowtime}/" ]then rm -rf "${targetpath}/${nowtime}/" echo "=======${targetpath}/${nowtime}/===?~H| ?~Y??~L?~U=="fiecho "===$nowtime ==="
创建定时任务
服务器的时间要同步,同步的方法微软公司授时主机(美国) time.windows.com台警大授时中心(台湾) asia.pool.ntp.org中科院授时中心(西安) 210.72.145.44网通授时中心(北京) 219.158.14.130调用同步: ntpdate asia.pool.ntp.org权限:chmod 777 filecrontab -e10 04 * * * /data/shell/mongobak 1>/data/log/crontab_mongo_back.file &10 02 * * * /shell/mongobakdelete 1>/data/log/crontab_mongo_delete.file &
阅读全文
1 0
- Mongodb自动备份脚本
- Linux下MongoDB实现自动备份脚本
- Windows下自动备份mongodb的bat脚本
- MongoDB 备份脚本
- mongodb数据库自动备份
- MongoDB 自动启动脚本
- MongoDB 自动启动脚本
- LINUX 自动备份脚本
- mysql自动备份脚本
- VSS自动备份脚本
- MYSQL自动备份脚本
- mysql自动备份脚本
- 自动备份脚本
- Oracle自动备份脚本
- 自动备份mysql脚本
- mysql自动备份脚本
- sharepoint自动备份脚本
- mysql自动备份脚本
- mysql Waiting for table metadata lock
- 吐槽DS f题
- 前端优化系列之域名收敛和域名发散
- 模板方法模式
- 微信支付的那些小事
- Mongodb自动备份脚本
- Maximal Rectangle leetcode java
- SQL注入之万能密码
- 焦点问题 获取 失去 重新获取
- 设计模式之工厂模式
- [编程题] 独立的小易
- C语言之网络编程(服务器和客户端)
- javascript数据类型转换
- HDU 6127 Hard challenge【极角排序】