fix: prevent false Gotify alerts by scanning only current log for real errors.
This commit is contained in:
parent
eb0656c844
commit
2588ebcfce
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user