欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2024-04-03 11:40:22
...
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

上一篇: php连接数据库的一些总结

下一篇: