自动删除Mysql备份(数组+for)

#!/bin/bash
#author:V
#Dispaly:auto delete mysql backup.

BACKDIR=(/home/11/mysqlbackup/ /home/full/)
DAYS=2
FILENAME="full*"
LOGNAME=/var/log/autodel.log
DATA=`date +%Y%m%d`
echo ${BACKDIR[*]}
for i in ${BACKDIR[*]}
do

find $i -name "$FILENAME" -type f -mtime +$DAYS -exec rm {} \; >> $LOGNAME 2>&1
if [ $? -eq 0 ];then
        echo "$DATA $i OK">>$LOGNAME
else
        echo "$DATA $i FAIL">>$LOGNAME
        exit 0
fi

done

 

你可能感兴趣的:(自动删除Mysql备份(数组+for))