一、采用定时器来来控制php脚本备份。不涉及时间间隔。php
二、脚本须要作的。mysql
a、调用系统压缩命令,生成根据日期时间的压缩包。算法
b、只保留最近7天内的数据。sql
用的的方法以下:code
rq=`date +%Y%m%d` zip -q -r $rq.zip /opt/mysql/test
最近七天的时间 算法 暂时没有好的思路ip
find 备份数据 -name "文件" -type f -mtime +7 -exec rm{};