MySQL dump 备份脚本

vim  db_all.sh

#!/bin/sh

logFile=/home/shell/db_backup.log

DATE=`date +‘%Y%m%d_%H_%M‘`

cd /home/data/backup/fullbak

        echo begin bak  alldb  $DATE >>$LogFile

/usr/local/mysql/bin/mysqldump -udbbak !$%   --single-transaction --master-data=2 --all-databases -R -E  -e -q --triggers| gzip > bak_pay_slave227-$DATE.sql.gz

        resultbak=$?

        echo result: $resultbak   $DATE end alldb bak  >>$LogFile

/bin/find /home/data/backup/fullbak  -mtime +2|xargs rm -f

注:记得创建备份用户