mysql全库备份数据库脚本


#!/bin/sh DATE=`date +%Y%m%d` DEL_DATE=$(date -d '-30 days' "+%Y%m%d") HOST=127.0.0.1:27017 USER=admin PASSWORD=123456 BACKUP_PATH="/backup/mongodbbackup/$DATE" date +%Y%m%d%H%M >>/data/log/mongodb_bak.log start() { cd /home/mongdb/ ./mongodump -h $HOST -u $USER -p $PASSWORD -o $BACKUP_PATH } execute() { start if [ $? -eq 0 ] then echo "mongodb back successfully!" >>/backup/mongodbbackup/log/mongodb_bak.log else echo "mongodb back fail!" >>/backup/mongodbbackup/log/mongodb_bak.log fi } execute rm -rf "/backup/mongodbbackup/${DEL_DATE}/"

 

posted on 2016-11-28 14:52  裤裆内隐藏杀气  阅读(144)  评论(0编辑  收藏  举报

导航