Skip to content

Lesson 9 of 9 · 28m

Operating Stateful Systems: Upgrades, Backups, and Recovery

The operating discipline for stateful platforms — safe upgrade order, backup consistency, restore drills, migration boundaries, and operator-assisted lifecycle management.

The worst time to discover your backup is only a volume snapshot is during a restore. Stateful operations reward paranoia and rehearsal. A correct-looking object graph means nothing if the database cannot replay its WAL, the backup encryption key is gone, or the restore process overwrites the only surviving copy.

Upgrades are ordered because correctness is ordered

A generic upgrade sequence looks like this:

  1. Verify backup freshness and restore procedure.
  2. Upgrade operator/control-plane components if required.
  3. Upgrade replicas or followers first.
  4. Fail over primary/leader deliberately.
  5. Upgrade the old primary.
  6. Verify replication lag, health, and application compatibility.

Do not encode this as blind ordinal restart logic. PostgreSQL, Kafka, Elasticsearch, etcd, and Redis all have different invariants. A chart can express rolling update policy; an operator can encode application-specific health gates. Humans still need a runbook when automation stops.

Backup consistency has layers

volume snapshot
    crash-consistent: like pulling power at one instant

application backup
    consistent at the database's logical or transactional boundary

restored service
    useful only if identity, secrets, configuration, and data agree

Tools such as Velero back up Kubernetes objects and can integrate volume snapshots. Database-native tools (pg_basebackup, WAL archiving, mysqldump where appropriate, mongodump/oplog tooling) understand application consistency. Often you need both: native backups for correctness, object backups for reconstruction.

Recovery is a designed user journey

Write down and test the exact path:

kubectl create namespace restore-drill
helm upgrade --install orders-db ./charts/orders-db -n restore-drill -f values-restore.yaml
# restore into a scratch cluster or namespace first

A restore drill should answer: which backup, which point in time, which credentials, which storage class, how long until ready, and how the application reconnects. Measure actual restore time. Recovery time objective is a measurement, not an aspiration.

Operators can help — and can hurt

Database operators automate provisioning, failover, credential rotation, backups, and upgrades. They are valuable because they encode operational knowledge. They are dangerous because people stop learning the underlying system. Before adopting one, inspect its failure behavior: what happens on split brain, full disk, failed backup, unavailable API server, or bad CRD input?

Migration boundaries

Application rollouts and schema/data migrations have different rollback properties. Keep destructive or expensive migrations behind explicit controls. Compatible-change-first deployment is boring, and boring is exactly what you want: add new shape, deploy writers/readers, migrate data, remove old shape later.

Field notes

  • Backup success means restorable success. Alert on failed backups and missing restore drills, not just job completion.
  • Keep encryption keys and restore credentials outside the blast radius of the cluster being protected.
  • Deleting a namespace is not a cleanup strategy for stateful data; PVCs, snapshots, and external resources need explicit handling.
  • Document when automation must be paused. Fighting an operator during manual recovery makes a bad day worse.

Was this lesson helpful?

Sign in to rate