diff --git a/backUpIncremental.sh b/backUpIncremental.sh index eb92c2c..e207429 100755 --- a/backUpIncremental.sh +++ b/backUpIncremental.sh @@ -43,14 +43,11 @@ cd $backUpPath # 更新上次备份的binlog文件名和位置 echo "$CURRENT_BINLOG $CURRENT_POSITION" > "last_backup.txt" -backup_files=() - -cd $backUpPath -find ${dbName}-incremental-*.sql.zip -type f -print0 | while IFS= read -r -d '' file; do - file_date=$(stat -c %Y "$file") - current_time=$(date +%s) - if (( (current_time - file_date) > 86400 )); then - backup_files+=("$file") +OLD_BACKUPS=() +for file in ${backUpPath}/${dbName}-incremental--*.sql.zip; do + file_date=$(echo "$file" | grep -oP "(?<=-$dbName-)\d{10}(?=.sql.zip)") + if [[ $((CURRENT_DATE - file_date)) -gt 600 ]]; then + OLD_BACKUPS+=("$file") fi done