Schedule icon
Query icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

ClickHouse Automated Backup and Disaster Recovery Sentinel

Audit ClickHouse system.backups on a schedule to detect failed backups, verify disaster recovery SLA recency, and alert Slack on anomalies.

Categories
DataInfrastructure

ClickHouse analytical data platforms frequently ingest terabytes of critical event data, but backup operations can fail silently due to object storage permission expiration, disk space exhaustion, or cluster mutation locks. This blueprint connects directly to ClickHouse via JDBC on a recurring schedule, queries the official system.backups catalog, audits recent backup executions, verifies that disaster recovery snapshots comply with SLA staleness limits, and dispatches detailed Slack notifications when failures occur.

How it works

  1. probe_backup_telemetry (io.kestra.plugin.jdbc.clickhouse.Query) queries the native ClickHouse system.backups system catalog over the configured lookback window. It aggregates total backup runs, counts failed operations (status != 'BACKUP_CREATED' or non-empty error), extracts the latest backup name and status, and calculates the exact elapsed time in hours since the latest successful snapshot. allowFailure: true ensures network unreachable conditions are caught gracefully.
  2. classify_backup_health (io.kestra.plugin.core.debug.Return) evaluates query outputs using declarative Pebble conditionals:
    • UNREACHABLE: The ClickHouse endpoint could not be contacted over JDBC.
    • MISSING_BACKUP: Zero successful backups exist within the entire lookback period.
    • CRITICAL: One or more backup jobs failed or logged non-empty error strings.
    • STALE: All recorded backups succeeded, but the most recent backup age exceeds max_stale_backup_hours.
    • HEALTHY: Backups are succeeding within SLA limits with zero errors.
  3. route_by_backup_health (io.kestra.plugin.core.flow.Switch) branches on the evaluated status:
    • HEALTHY: Writes an informational confirmation log with backup size and file counts.
    • STALE: Sends an SLA alert to Slack warning that backup snapshots have stalled.
    • CRITICAL: Sends an incident alert to Slack containing the failed backup name and exact error details.
    • MISSING_BACKUP: Triggers an alert warning that disaster recovery coverage is absent.
    • UNREACHABLE: Dispatches an unreachable endpoint alert to on-call engineers.
  4. log_audit_summary (io.kestra.plugin.core.log.Log) records an immutable summary log entry across all executions, establishing an auditable compliance trail in Kestra execution history.
  5. The top-level errors handler dispatches a Slack webhook alert if any unexpected task error occurs, preventing silent monitoring blackouts.
  6. daily_backup_audit_schedule triggers the sentinel daily at 04:00 UTC (configured with disabled: true for initial onboarding).

What you get

  • Proactive detection of failed ClickHouse backups before disaster recovery incidents occur.
  • Automated verification of backup recency against Recovery Point Objective (RPO) SLAs.
  • Context-rich Slack notifications containing exact error messages from system.backups.
  • Agentless telemetry extraction using native ClickHouse SQL and standard JDBC connectivity.
  • An immutable execution history of backup audits for compliance and disaster recovery reporting.

Who it's for

  • Database Reliability Engineers (DBREs) and Platform Engineers maintaining ClickHouse clusters.
  • Data Engineers responsible for warehouse data durability, backup pipelines, and compliance audits.
  • Site Reliability Engineers (SREs) who require automated verification of disaster recovery readiness.

Why orchestrate this with Kestra

Custom bash cron scripts querying database endpoints often fail silently without leaving execution trails, and hard-coded database passwords in scripts create severe security vulnerabilities. Kestra orchestrates the monitoring lifecycle declaratively with encrypted secret injection, granular task retries, visual execution tracking, and seamless integration into automated escalation workflows.

Prerequisites

  • A running ClickHouse server or cluster (accessible locally via Docker clickhouse/clickhouse-server:latest on port 8123 or over the network).
  • A ClickHouse user account with SELECT privilege on the system.backups table.
  • A Slack Incoming Webhook URL for receiving incident notifications.

Secrets

  • CLICKHOUSE_PASSWORD: ClickHouse database user password (required).
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used for dispatching alert messages (required).

Quick start

  1. Configure the CLICKHOUSE_PASSWORD and SLACK_WEBHOOK_URL secrets in your Kestra namespace.
  2. Import this blueprint into your Kestra instance and adjust clickhouse_host and clickhouse_port to point to your ClickHouse instance.
  3. Click Execute to run a manual verification pass.
  4. Verify execution logs and check that status outputs HEALTHY.
  5. Enable the daily_backup_audit_schedule trigger to begin automated daily disaster recovery monitoring.

How to extend

  • Add automated backup trigger: In the MISSING_BACKUP or STALE branch, trigger an ad-hoc ClickHouse BACKUP DATABASE execution task to automatically initiate a catch-up snapshot.
  • Add multi-channel escalation: Route CRITICAL alerts to PagerDuty or Opsgenie using Kestra notification plugins for immediate off-hours paging.
  • Export metrics: Append a DuckDB or Prometheus push task to graph backup size growth trends and backup duration over time.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.