linux mysql 自动备份
backmysql.sh
backdir="/usr/local/backup/"
mysqlbindir="/usr/local/mysql/bin/"
backdatabase="easylife"
keepdays=30
mysqlhotcopy -u root -p 'huewrtfub@$@#43afewr' ${backdatabase} ${backdir}
tar zcvfP ${backdir}${backdatabase}_db_$(date +"%Y%m%d" --date="-1 day").tar ${backdir}${backdatabase}
rm -rf ${backdir}${backdatabase}
rm -rf ${backdir}${backdatabase}_db_$(date +"%Y%m%d" --date="-${keepdays} day").tar
59 23 * * * root /usr/local/backup/backmysql.sh
service crond restart
backmysql.sh
backdir="/usr/local/backup/"
mysqlbindir="/usr/local/mysql/bin/"
backdatabase="easylife"
keepdays=30
mysqlhotcopy -u root -p 'huewrtfub@$@#43afewr' ${backdatabase} ${backdir}
tar zcvfP ${backdir}${backdatabase}_db_$(date +"%Y%m%d" --date="-1 day").tar ${backdir}${backdatabase}
rm -rf ${backdir}${backdatabase}
rm -rf ${backdir}${backdatabase}_db_$(date +"%Y%m%d" --date="-${keepdays} day").tar
59 23 * * * root /usr/local/backup/backmysql.sh
service crond restart