Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Verify HashiCorp Vault Backups Are Fresh and Restorable

Verify HashiCorp Vault raft backups are fresh and restorable, then escalate stale snapshots and failed restore drills to Slack and GitHub.

Categories
Infrastructure

A backup job that only reports "taken" proves nothing about recovery. This blueprint runs the second half of the promise. A keyed webhook triggers an on-demand verify and a disabled weekly schedule reserves drill day. The flow asks the official Vault container for a raft snapshot, keeps a bundled manifest when no leader answers, and turns that manifest into a freshness verdict carrying the snapshot age and id. A stale snapshot opens a labeled GitHub issue and pings Slack, then a restore drill rebuilds the snapshot into a scratch namespace and a second pass over the drill output decides whether the backup is genuinely restorable. A failed drill escalates to Slack before the verdict, age, snapshot id, and verification flag are published as outputs.

How it works

  1. on_demand_verify (io.kestra.plugin.core.trigger.Webhook) exposes a keyed URL for a post-incident or pre-upgrade check, and weekly_drill_day (io.kestra.plugin.core.trigger.Schedule, cron 0 6 * * 3) ships disabled: true so nothing runs until drill day is switched on.
  2. drill_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared filesystem so the capture, the parser, and the restore drill all see the same backup.snap.
  3. capture_snapshot (io.kestra.plugin.scripts.shell.Commands on the io.kestra.plugin.scripts.runner.docker.Docker runner, image hashicorp/vault:1.17.2) writes a snapshot-manifest.json fixture with a heredoc, then runs vault operator raft snapshot save backup.snap || true. When a leader answers, the manifest is rewritten from the real capture with the snapshot id, the UTC timestamp, and the byte size; when nothing answers, the fixture keeps the flow deterministic offline. entryPoint: [] clears the image entrypoint so the script runs instead of a server command.
  4. evaluate_freshness (io.kestra.plugin.scripts.python.Script on python:3.12-slim) parses taken_at, computes whole days of age against max_snapshot_age_days, and emits verdict, snapshot_age_days, snapshot_id, and stale through Kestra's outputs protocol. An unparseable timestamp reports age -1 and counts as stale, so missing evidence fails closed.
  5. check_freshness (io.kestra.plugin.core.flow.If) branches on stale. When true, open_stale_issue (io.kestra.plugin.github.issues.Create) files a labeled issue with the age and budget, and alert_stale_backup (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts the same numbers to Slack. When false, log_fresh_backup records the all-clear.
  6. restore_drill runs vault operator raft snapshot restore -check backup.snap scratch/restored.snap > restore-check.txt 2>&1 || true inside the same container image and namespace drill-scratch, then appends restore_check=passed or restore_check=failed based on whether the restore target came back non-empty.
  7. parse_restore reads restore-check.txt and emits verified plus a short reason. check_restore (io.kestra.plugin.core.flow.If) escalates to escalate_unrestorable when verified == false, while a verified drill lands in log_restorable.
  8. The errors block alerts Slack whenever a step breaks outright, because a dead drill looks a lot like a quiet pass.

What you get

  • Gateable outputs: verdict, snapshot_age_days, snapshot_id, and verified are available to any downstream flow or dashboard.
  • Proof of restorability instead of proof of scheduling, the restore runs on every drill and its evidence is kept as restore-check.txt.
  • Escalation where engineers already work, a labeled GitHub issue plus a Slack message when the backup is stale, and a Slack alert when it will not restore.
  • An audit trail, every execution is a dated record of snapshot age, snapshot id, and restore outcome.

Who it's for

  • Platform and SRE teams who must show that Vault backups are recovered on a schedule, not merely taken.
  • Security engineers treating untested backups as an availability and compliance risk.
  • On-call engineers who want stale or unrestoreable backups to arrive in Slack and in the backlog automatically.

Why orchestrate this with Kestra

Snapshot cron jobs are easy to add and easy to stop watching. Kestra supplies the loop around the tool: a keyed webhook for on-demand verification, a disabled-by-default weekly schedule for drill day, a hermetic container so the Vault CLI version lives in the flow file, a freshness branch that turns age into tracked work, a restore branch that turns evidence into an alert, and execution history with the drill output attached. A cron line running vault operator raft snapshot save gives you none of that, it only writes a file that nobody re-reads.

Prerequisites

  • A worker with Docker access, both shell steps run in hashicorp/vault:1.17.2 and both parsers in python:3.12-slim.
  • A Vault server address reachable from the worker for a real drill. Without one the flow still completes on the bundled manifest and reports verified false, which is the honest answer for an unreachable backup target.
  • A token that can run operator raft snapshot against the target cluster, stored as VAULT_TOKEN.
  • A GitHub token that can open issues in the runbooks repository (classic PAT scope repo, or fine-grained Issues: write).
  • A Slack incoming webhook for the stale and unrestorable alerts plus failure notifications.

Secrets

  • VAULT_DRILL_WEBHOOK_KEY: key segment guarding the on-demand webhook URL, anyone holding it can start a drill.
  • VAULT_TOKEN: token presented to the Vault server for the snapshot capture and the restore drill.
  • GITHUB_TOKEN: token used to open the stale backup issue.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL.

Quick start

  1. Add the four secrets to your Kestra namespace.
  2. Set vault_addr to the cluster under test and lower max_snapshot_age_days to 1 to watch a stale backup escalate.
  3. Run the flow once with defaults and read verdict, snapshot_age_days, snapshot_id, and verified in the outputs.
  4. Trigger on_demand_verify at /api/v1/{tenant}/executions/webhook/{namespace}/vault-backup-verify-drill/{VAULT_DRILL_WEBHOOK_KEY}, then enable weekly_drill_day once the worker can reach Vault.
  5. Point repository in open_stale_issue at your own runbooks repository before the first stale run.

How to extend

  • Verify more clusters by fanning the vault_addr input out with a Loop over a cluster list, one execution per cluster.
  • Ship restore-check.txt to S3 with io.kestra.plugin.aws.s3.Upload so drill evidence survives outside Kestra.
  • Add a core.flow.Sleep and a second capture after the drill to prove a fresh snapshot lands within the recovery point objective.
  • Turn a failed drill into a red run by adding io.kestra.plugin.core.execution.Fail under check_restore.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.