fix: prevent false Gotify alerts by scanning only current log for real errors.

This commit is contained in:
Nick Heppler 2025-05-03 14:10:15 -04:00
parent eb0656c844
commit 2588ebcfce

View File

@ -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 {} \; find "$BACKUP_DIR" \( -name "docker_backup_*.tar.gz" -o -name "docker_backup_*.log" \) -type f -mtime +$RETENTION_DAYS -exec rm -f {} \;
} }
# === Error Scanning === # === Error Scanning for Current Run Only ===
scan_logs_for_errors() { scan_current_log_for_errors() {
log "🔍 Scanning logs for errors" log "🔍 Scanning current log for errors"
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")
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)
if [[ -n "$ERRORS" ]]; then if [[ -n "$LOG_ERRORS" ]]; then
gotify_error_notify "$ERRORS" gotify_error_notify "$LOG_ERRORS"
fi fi
} }
@ -112,6 +106,6 @@ backup_directories
start_containers start_containers
cleanup_old_files cleanup_old_files
scan_logs_for_errors scan_current_log_for_errors
log "✅ Docker backup job completed" log "✅ Docker backup job completed"