#!/bin/sh
backup_dir=/data/xtrabackup
DATE=`date +%Y-%m-%d`
#DATE_NOW=`date +%Y-%m-%d.%H%M`
DATE_NOW=`date +%Y-%m-%d`
PATH=/usr/local/mysql/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
binog保留7天
binlog=/data/binlogserver
binlog_Rtime='7'
#备份目录xtrabackup保留两周
xtrabackup_dir="/data/xtrabackup/"
xtrabackup_Rtime='14'
OLDDATE=`date +%Y-%m-%d -d "14 days ago"`
full_sql_dir="/data/mysql_backup/fulltable"
table_dir="/data/mysql_backup/tb_trcevt"
sql_Rtime='14'
function cron_del
{
dir=$1
time=$2
find $dir -mtime +$time -exec rm -rf {} \;
}
del_date ()
{
OLD_DATE=$1
dir=$1
cd $dir
rm -rf $OLD_DATE
echo ”完成删除14天前的xtrabackup数据日期为${OLDDATE}----” >> ${backup_dir}/bak_del.log
}
cd
#rm -rf ${OLDDATE}
#
cron_del $binlog $binlog_Rtime
del_date ${backup_dir} $OLDDATE
cron_del $full_sql_dir $sql_Rtime
cron_del $table_dir $sql_Rtime
定时删除脚本
最新推荐文章于 2024-08-13 13:38:17 发布