mysql备份+报警
精选 转载#!/bin/bash
BakDir=/backup/mysql/full
LogFile=/var/log/mysql-dbispconfig-backup.log
DATE=`date +%Y-%m-%d`
DumpFile=$DATE.sql
GZDumpFile=$DATE.sql.tar.gz
backup_error=/backup/mysql/backup_error
compress_error=/backup/mysql/compress_error
email1="daigh@qian-gao.com"
email2="qubq@qian-gao.com"
echo -e "\n" >>$LogFile
echo "===========> $DATE <============= " >>$LogFile
echo "$(date +"%H:%M:%S") begin back DNS database ">>$LogFile
cd $BakDir
mysqldump -u root -pqian-gao.com dabispconfig --default-character-set=utf8 >$DumpFile 2>/backup/mysql/backup_error
if [ $? == 0 ]
then
echo "at $(date +"%H:%M:%S") the backup Done,now begin compress the sql file" >>$LogFile
tar czvf $GZDumpFile $DumpFile 2>/backup/mysql/compress_error
if [ $? == 0 ]
then
echo "at $(date +"%H:%M:%S") the $GZDumpFile Backup Success!" >>$LogFile
echo "finish!" >>$LogFile
rm -f $DumpFile
else
mail -s "compress_error" $email1 <$compress_error
mail -s "compress_error" $email2 <$compress_error
fi
else
mail -s "backup_error" $email1 <$backup_error
mail -s "backup_error" $email2 <$backup_error
fi
上一篇:mysql备份
下一篇:mysqldump备份mysql
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
mysql 备份与恢复
mysql 逻辑备份与物理备份 (不含gtid)
mysql 数据 数据库