From 2588ebcfce85e967a9c941929ca0725484af2cdb Mon Sep 17 00:00:00 2001 From: Nick Heppler Date: Sat, 3 May 2025 14:10:15 -0400 Subject: [PATCH] fix: prevent false Gotify alerts by scanning only current log for real errors. --- docker_backup.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/docker_backup.sh b/docker_backup.sh index a356cef..eb66830 100644 --- a/docker_backup.sh +++ b/docker_backup.sh @@ -87,19 +87,13 @@ cleanup_old_files() { find "$BACKUP_DIR" \( -name "docker_backup_*.tar.gz" -o -name "docker_backup_*.log" \) -type f -mtime +$RETENTION_DAYS -exec rm -f {} \; } -# === Error Scanning === -scan_logs_for_errors() { - log "🔍 Scanning logs for errors" - ERRORS="" - while IFS= read -r logfile; do - LOG_ERRORS=$(grep -Ei "error|failed|❌" "$logfile") - if [[ -n "$LOG_ERRORS" ]]; then - ERRORS+="\n$(basename "$logfile"):\n$LOG_ERRORS\n" - fi - done < <(find "$BACKUP_DIR" -name "docker_backup_*.log" -type f -mtime -$RETENTION_DAYS) +# === Error Scanning for Current Run Only === +scan_current_log_for_errors() { + log "🔍 Scanning current log for errors" + LOG_ERRORS=$(grep -Ei "error|failed|❌" "$LOG_FILE" | grep -vEi "Gotify error notification sent|Uptime Kuma check-in sent|Scanning current log for errors") - if [[ -n "$ERRORS" ]]; then - gotify_error_notify "$ERRORS" + if [[ -n "$LOG_ERRORS" ]]; then + gotify_error_notify "$LOG_ERRORS" fi } @@ -112,6 +106,6 @@ backup_directories start_containers cleanup_old_files -scan_logs_for_errors +scan_current_log_for_errors log "✅ Docker backup job completed"