Skip to content

A Fresh Backup Is Only One Clock

S5·E22

I needed to know which clock I was looking at

A backup dashboard can say the last job ran four minutes ago. It is tempting to call that four minutes of possible data loss, or to assume the service will be back in four minutes. Those are separate claims. In a parallel thread on 30 July, I wanted a recovery dashboard that would make it hard to confuse them.

The initial plan was small. Measure how long ago the last native backup succeeded, how long the job ran, and how recently PostgreSQL archive health had been checked. Use the source that already owned each timestamp. Keep the backup methods and retention policy in place. Make the dashboard explicit about what could be decided from each value. I set those distinctions as the operational requirement. Agent-assisted implementation turned them into recording rules and checks.

An SLI, or service level indicator, is an observed measurement. An SLO is a target for such a measurement. The values I had were a baseline. They gave me something to reason from before setting commitments I could not yet defend.

An engineer holds a dip gauge on a pier opposite a boat in its cradle

A current reading and a completed recovery drill are separate observations. Conceptual illustration.

One dashboard, four separate readings

The backup freshness calculation starts with the last time a Kubernetes CronJob succeeded. Job duration comes from completion minus start for the latest completed job. Verification freshness starts at the last archive-health check. I kept the recovery-point reading separate because it has a different clock and source.

PostgreSQL’s write-ahead log, usually called WAL, records changes as they happen. With a suitable base backup and continuous WAL archives, PostgreSQL can replay changes to a selected point. The age of the latest archived WAL gives a recovery-point age for that specific archive. It does not establish an end-to-end restore time, and it does not become the recovery-point age of another database simply because both systems use PostgreSQL.

The archive-health job reported a read-only timestamp into Prometheus Pushgateway, which holds metrics from short-lived jobs until Prometheus can scrape them. A Prometheus recording rule made the calculation queryable under a stable metric name. The application labels were bounded so that individual job identifiers and timestamps would not create fresh time series for every run.

Follow the decision

Archive jobReads WAL clockPushgatewayHolds timestampPrometheus ruleNow minus archiveDashboardPoint age only
Archive jobReads WAL clockPushgatewayHolds timestampPrometheus ruleNow minus archiveDashboardPoint age only
The four stages show the archived WAL age signal. A different observation measures how long recovery takes.

Historical source excerpt · prometheus-rules.yaml at 60018ae1, lines 2616–2620

          - record: rootweaver_recovery_rpo_seconds
            expr: time() - rootweaver_postgres_last_archived_wal_timestamp_seconds{postgres="vault-postgres"}
            labels:
              recovery_method: postgresql_wal
              workload: vault_postgres
Explain this code line by line
  1. Assign the recorded result its stable metric name.
  2. Subtract the latest Vault PostgreSQL archived-WAL time from evaluation time.
  3. Start the block of static category labels.
  4. Identify the recovery method as PostgreSQL WAL.
  5. Identify which workload this expression applies to.

Illustrative calculation. Suppose the current time is 12:10:00 and the latest archived WAL timestamp is 12:01:34. The difference is 506 seconds, or 8 minutes 26 seconds. If the latest archive-health check completed 91 seconds ago, the check is recent and the archived recovery point is older. The values can coexist. The check age measures when we looked. The WAL age measures how far the archive had advanced.

Two analog timers beside a measured rope

Two clocks can both be accurate and still answer different questions. Conceptual illustration.

The retry that looked like a critical failure

The first post-rollout archive-health job briefly failed to reach Pushgateway. Its configured retry succeeded. The alert still fired because the Kubernetes Job’s failed-attempt count retained the earlier failure. The count answered whether an attempt had failed. I needed the alert to answer whether the job had reached a completed state despite that failure.

The correction ignored completed Jobs in the failure alert while retaining the signal for a final failure. That changed the decision the alert was making. It also preserved the diagnosis of a transient connection problem without leaving an operator with a critical alarm for a job that had recovered.

Check the dashboard against the system beneath it

The 30 July report records Flux applying the recording rules. Prometheus restarted during the configuration rollout and replayed its own local time-series WAL. I kept that event distinct from the Vault PostgreSQL WAL we were measuring. Once Prometheus was ready, the recorded baseline included:

Native backup workloadLatest job durationBackup freshness
Qdrant277 s70,319 s
FalkorDB161 s70,435 s
Langfuse ClickHouse6 s1,355 s
Langfuse Valkey11 s63,686 s

The same report gives 91 seconds for PostgreSQL archive-health verification freshness. A later post-correction read gives 506 seconds for Vault PostgreSQL archived WAL age, backed by the direct gauge. These were observations, and the report provides no continuously measured end-to-end restore duration. To measure that duration I would start the clock at drill initiation and stop it only when a restored service meets its declared checks.

The practical lesson was to make each metric name traceable to its clock, source and decision. The finale applies that to a subtler signal: did the agent consult the right layer of memory first, and did we have enough eligible decisions to trust the percentage?

Glossary and primary references

WAL

Write-ahead log. PostgreSQL records changes so they can be recovered by replay.

Primary reference

CronJob

Kubernetes controller that creates Jobs on a repeating schedule.

Primary reference

SLI

A measured indicator used to evaluate a service characteristic.

Primary reference

Recovery-point age

Elapsed time since the latest recovery source point observed for this method.

Primary reference

Prometheus recording rule

A named, periodically evaluated expression whose result is stored as a time series.

Primary reference