###### 备份数据库的脚本############### ################## #author rrhelei@126.com# ################## user=backup passwd=MANAGER host=192.168.1.250 date=`date +%Y%m%d` mysql_bin=/usr/local/mysql/bin $mysql_bin/mysqldump-u$user -p$passwd -h$host --single-transaction test > /databackup/test/$date.sql if[ -f /databackup/test/$date.sql ] then cd /databackup/test;tar -cvzf $date.sql.tar.gz $date.sql rm -fr $date.sql fi find/databackup/test/ -type f -name"*sql*" -mtime +30| xargs rm -fr {};
原文地址:http://suifu.blog.51cto.com/9167728/1758022