本文共 953 字,大约阅读时间需要 3 分钟。
#!/bin/bash #This is mysql full backup scripts user=root passwd=root databak_dir=/home/xinhua/mysql_backup/chint_mes/ eMailFile=$databak_dir/email.txt database=xtra_test echo " " >> $eMailFile echo "---------------------------------" >> $eMailFile echo $(date +"%y-%m-%d %H:%M:%S") >> $eMailFile innobackupex --user=$user --password=$passwd --database=$database $databak_dir/full_bak if [ $? == 0 ]; then echo "全量备份成功 DataBase Backup Success" >> $eMailFile else echo "全量备份失败 DataBase Backup Fail!" >> $eMailFile #发送到邮件箱可以根据情况选用 # echo `date` "全量备份失败" | mail -s "全量备份失败" XXXXXXXXXX@qq.com fi #此处时间可以根据具体需要更改 evenday=$(date -d "7 days ago" +%Y-%m-%d) delsevfilename=`find $databak_dir/full_bak -name $delsevenday* -print|awk -F / '{print $NF}'` delfile="$databak_dir/full_bak/$delsevfilename" if [ -f $delfile ];then rm -rf $delfile fi rm -rf $databak_dir/inc_bak/* TIME=$(date +%Y%m%d%H%M%S) mysql -u root -proot -e "purge master logs before ${TIME}" ~ ~转载地址:http://pyuhj.baihongyu.com/