时间:2021-07-01 10:21:17 帮助过:2人阅读
echo "备份目录:$BAK_DIR"
else
echo -e "\033[34m数据备份出错,请检查....\033[0m"
fi
#自动删除30天以前的备份数据
find $BAK_DIR/ -mtime +30 |xargs rm -rf {} \;
if [ $? -eq 0 ];then
echo -e "\033[37m删除30天以前的备份数据完成...\033[1m"
else
echo -e "\033[37m命令执行出错或找不到目录,请检查\033[0m"
fi
#创建自动备份计划任务
grep "back_mysql" /var/spool/cron/root >> /dev/null
if [ $? -ne 0 ];then
echo "30 20 * * 5 /root/shell/back_mysql > /tmp/mysql.log 2>&1" >> /var/spool/cron/root
fi
mysql自动备份脚本
标签: