mysqldump全备份脚本mysqlallbackup.sh-->(旧文档整理

页面导航:首页 > 数据库 > Mysql > mysqldump全备份脚本mysqlallbackup.sh-->(旧文档整理

mysqldump全备份脚本mysqlallbackup.sh-->(旧文档整理

来源: 作者: 时间:2016-02-05 10:56 【

mysqldump全备份脚本mysqlallbackup.sh--(旧文档整理)库小,大概16G左右,每天增量很小,不到100M,所以用mysqldump每天全量备份,将备份结果信息发送到email通知DBA。mysqlallbackup.sh:MySQL DataBase F
dump全备份脚本mysqlallbackup.sh-->(旧文档整理)
 
库小,大概16G左右,每天增量很小,不到100M,所以用mysqldump每天全量备份,将备份结果信息发送到email通知DBA。
 
mysqlallbackup.sh

:MySQL DataBase Full Backup.
# Use mysqldump --help get more detail.
# 20.20.21.11 : mysqla
# 
set -x
# define data directy
mysqlDir=/usr/local/mysqla
# defile user,pwd
dataBackupDir=/data/backup
eMailFile=$dataBackupDir/email.txts
# email
eMail=
# backup file
logFile=$dataBackupDir/mysqlbackup.log
#DATE=`date -l`
echo "full backup of database on 10.80.21.12 begin ......" > $eMailFile
echo $(date +%Y-%m-%d-%H:%M:%S) >> $eMailFile


cd $dataBackupDir
# defile filename
dumpFile=20_20_21_11_mysqla_$(date +%Y%m%d_%H%M%S).sql
GZDumpFile=20_20_21_11_mysqla_$(date +%Y%m%d_%H%M%S).sql.tar.gz
# $mysqlDir/bin/mysqldump  -uroot -pxxxxx --skip-opt --default-character-set=utf8 --extended-insert=false --triggers -R --hex-blob --all-databases --flush-logs --delete-master-logs --delete-master-logs --lock-tables=false  > $dumpFile
/usr/local/mysqla/bin/mysqldump  -uroot -p'MBkangsheng#@!2010611'  -S /tmp/mysqla.sock --default-character-set=utf8 --extended-insert=false --triggers -R --skip-opt --hex-blob --all-databases --master-data=1  --flush-logs  >$dumpFile
if [[ $?==0]]; then
echo "BackupFileName:$GZDumpFile" >> $eMailFile
echo "DataBase Backup Success!" >> $eMailFile
else
echo "DataBase Backup Fail!" >> $emailFile
fi
echo "--------------------------------------------------------" >> $logFile
cat $eMailFile >> $logFile

# send email
cat $eMailFile | mail -s "MySQL Backup" $eMail

 


Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<