本文共 1005 字,大约阅读时间需要 3 分钟。
#!/bin/bash #This is mysql daily backup scripts user=root passwd=root database=xtra_test databak_dir=/home/xinhua/mysql_backup/chint_mes eMailFile=$databak_dir/email.txt #此处的时间可根据需要自行设定 last=$(date -d "3 minutes ago" +%Y-%m-%d_%H-%M) filename=`find $databak_dir/inc_bak -name $last* -print|awk -F / '{print $NF}'` echo " " >> $eMailFile echo "---------------------------------" >> $eMailFile echo $(date +"%y-%m-%d %H:%M:%S") >> $eMailFile innobackupex --user=$user --password=$passwd --database=$database --incremental --incremental-basedir=$databak_dir/inc_bak/$filename $databak_dir/inc_bak if [ $? == 0 ]; then echo "基于增量备份的增量备份成功 DataBase Backup Success" >> $eMailFile else echo "基于增量备份的增量备份失败 DataBase Backup Fail!" >> $eMailFile #发送到邮件箱可以根据情况选用 # echo `date` "基于增量量备份的增量备份失败" | mail -s "基于增量备份的增量备份失败" XXXXXXXXXX@qq.com fi echo "--------------------------------------------------------" >> $eMailFile TIME=$(date +%Y%m%d%H%M%S) mysql -u root -proot -e "purge master logs before ${TIME}" ~ ~ ~ ~ ~ ~转载地址:http://tyuhj.baihongyu.com/