BACKUP_DAYS=7 REDIS_BACKUP_FILES_ARR=($REDIS_BACKUP_FILES) CUR_DAY=$(date +%Y%m%d) EXPIRED_DAY=$(date -d "$BACKUP_DAYS days ago" +%Y%m%d)
for f in${REDIS_BACKUP_FILES_ARR[@]} do tempFPath=$(echo"$REDIS_DATA_HOME$f" | awk 'gsub(/^ *| *$/,"")') if [ ! -f "$tempFPath" ]; then echo"$tempFPath not exist!" exit 1 fi
tempBPath="$tempFPath.$CUR_DAY" if [ -f "$tempBPath" ]; then echo"backup-file [$tempBPath] exist already." else echo"start backup $tempFPath to $tempBPath." cp $tempFPath$tempBPath fi
#delete backup file by expired tempEPath="$tempFPath.$EXPIRED_DAY" if [ -f "$tempEPath" ]; then echo"delete backup-file [$tempEPath]." rm -f $tempEPath #else #echo "backup-file [$tempEPath] not exist." fi done