当前位置:Gxlcms > mysql > mysqldump全备份脚本mysqlallbackup.sh-->(旧文档整理)_MySQL

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

时间:2021-07-01 10:21:17 帮助过:24人阅读

mysqldump

bitsCN.com

mysqldump全备份脚本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 directymysqlDir=/usr/local/mysqla# defile user,pwddataBackupDir=/data/backupeMailFile=$dataBackupDir/email.txts# emaileMail=mchdba@tom.com# backup filelogFile=$dataBackupDir/mysqlbackup.log#DATE=`date -l`echo "full backup of database on 10.80.21.12 begin ......" > $eMailFileecho $(date +%Y-%m-%d-%H:%M:%S) >> $eMailFilecd $dataBackupDir# defile filenamedumpFile=20_20_21_11_mysqla_$(date +%Y%m%d_%H%M%S).sqlGZDumpFile=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  >$dumpFileif [[ $?==0]]; thenecho "BackupFileName:$GZDumpFile" >> $eMailFileecho "DataBase Backup Success!" >> $eMailFileelseecho "DataBase Backup Fail!" >> $emailFilefiecho "--------------------------------------------------------" >> $logFilecat $eMailFile >> $logFile# send emailcat $eMailFile | mail -s "MySQL Backup" $eMail


bitsCN.com

人气教程排行