标签:备份 his 定时任务 dev delete pass 绝对路径 gzip dump
backup.sh 脚本
# Name:backup.sh # This is a ShellScript For Auto DB Backup and Delete old Backup #备份地址 backupdir=/data/backup #备份文件后缀时间 time=_` date +%Y_%m_%d_%H_%M_%S ` #需要备份的数据库名称 db_name= #mysql 用户名 #db_user= #mysql 密码 #db_pass= #mysqldump命令使用绝对路径 /usr/local/mysql/bin/mysqldump $db_name | gzip > $backupdir/$db_name$time.sql.gz #删除7天之前的备份文件 find $backupdir -name $db_name"*.sql.gz" -type f -mtime +7 -exec rm -rf {} \; > /dev/null 2>&1
添加定时任务
crontab -e
添加任务
0 04 * * * /bin/sh /usr/local/shell/backup.sh >> /data/wwwlogs/backup.log
标签:备份 his 定时任务 dev delete pass 绝对路径 gzip dump
原文地址:https://www.cnblogs.com/rubekid/p/9583109.html