# Send mail for backup result.
echo "" >>${logFile}
echo "Below is detail log for current innobackup.">>${logFile}
cat ${logDir}/bak_${ts}.log >>${logFile}
mailadd='jack@12306.cn,ww@12306.cn'
if [ -e "${logFile}" ]; then
status=`grep -i "innobackupex: completed OK!" ${logFile}`
if [ -n "${status}" ]; then
cat ${logFile} |mutt -s "Successful backup for MySQL hotbackup on `hostname`." $mailadd
else
cat ${logFile} |mutt -s "Failed backup for MySQl hotbackup on `hostname`." $mailadd
fi
else
echo "The hotbackup logfile was not found on `hostname`." | \
mutt -s "Failed backup for MySQl hotbackup on `hostname`." $mailadd
fi
exit
3、调用示例
SHELL> more call_innobk.sh
#!/bin/bash
/db_scripts/innobk.sh --backup-dir=/data/backup --host=127.0.0.1 --port=3306 --user=innobk --password=InnoBK
SHELL> crontab -l
0 3 * * * /db_scripts/call_innobk.sh
SHELL> cd /data/backup
SHELL> ls
checkpoint log physical
SHELL> cd physical/
SHELL> ls
20141228 20141231 20150104 20150107
SHELL> cd 20150107
SHELL> ls -hltr
total 16K
drwxr-xr-x 9 root root 4.0K Jan 7 03:05 base_20150107 #全备
drwxr-xr-x 9 root root 4.0K Jan 8 03:04 inc_20150108 #增备
drwxr-xr-x 9 root root 4.0K Jan 9 03:03 inc_20150109 #增备
drwxr-xr-x 9 root root 4.0K Jan 10 03:03 inc_20150110 #增备
用XtraBackup实现MySQL的主从复制快速部署【主不锁表】