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"