#!/bin/sh
backupdir=/data/mysql_backup
#备份位置 /data/mysql_backup 请确保文件夹存在并具有读写权限
time=` date +%Y%m%d%H `
mysqldump -h 主机IP -u 帐号 -p密码 要备份的数据库名字 | gzip > $backupdir/backup_ams_data_$time.sql.gz
# delete 7 days ago
find $backupdir -name "backup_ams_data_*.sql.gz" -type f -mtime +7 -exec rm {} \; > /dev/null 2>&1