代码:
#!/bin/bash
# Name:bakmysql.sh
# This is a ShellScript For Auto DB Backup and Delete old Backup
#
backupdir=/bak/mysqlbak
time=` date +%Y%m%d%H `
mysql_bin_dir/mysqldump -u user -ppassword dataname1 | gzip > $backupdir/name1$time.sql.gz
mysql_bin_dir/mysqldump -u user -ppassword dataname2 | gzip > $backupdir/name2$time.sql.gz
#
find $backupdir -name "name_*.sql.gz" -type f -mtime +5 -exec rm {} \; > /dev/null 2>&1