Backup and disaster recovery
What to back up in a cluster and how: etcd snapshots for the control plane, Velero for namespaces and volumes, GitOps rebuilds, and rehearsed restores.
The control planeVolume snapshots, expansion and stateful dataArgo CD in practice
Backup and disaster recovery
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A cluster's state is two things: API objects in etcd, and data in persistent volumes. A backup plan must cover both, and Secrets in etcd snapshots need the same protection as the Secrets themselves.
- An etcd snapshot is a point-in-time copy of every object, cheap to take and the only way to restore a self-managed control plane exactly. Managed services handle etcd for you but don't back up your workloads.
- Velero backs up selected namespaces or resources through the API, plus volume snapshots or file-level copies, to object storage, and restores them into the same or a different cluster.
- GitOps repositories are a rebuild path, not a backup. They recreate declared objects but not volume data, generated Secrets, or state controllers wrote.
- Set RPO and RTO per workload, store backups outside the cluster's account or region, and rehearse restores regularly. An untested backup is a hope.
- Restoring a whole etcd snapshot rewinds the entire cluster to that moment, including object UIDs and resourceVersions, so controllers and clients see a jump back in time.
Bad days come in sizes
Someone runs kubectl delete namespace payments in the wrong context. A storage bug corrupts a database volume. An etcd disk fails on a three-member control plane, then a second one does. A region goes dark. Each needs a different recovery, and the time to find out which tool covers which disaster is before it happens.
Disaster recovery planning starts with two numbers per workload: RPO (recovery point objective, how much data you can lose) and RTO (recovery time objective, how long you can be down). Then you work out what state exists and how each piece comes back.
Two kinds of state
A cluster’s state lives in exactly two places:
- API objects in etcd: Deployments, Services, ConfigMaps, Secrets, CRDs and custom resources, RBAC, everything you can
kubectl get. - Data in persistent volumes: databases, uploads, queues, whatever your StatefulSets write.
Container images live in registries, and nodes are cattle. Neither needs cluster backups, though registries need their own.
etcd snapshots
On a self-managed control plane, an etcd snapshot is the complete set of API objects at one revision. The lab cluster’s etcd 3.6.6 served one over its HTTP gateway, and a small Go program using etcd’s own etcdutl snapshot library (v3.6.6) checked and restored it:
$ snapshot status etcd.db
hash=15e47ba revision=4653 totalKeys=660 totalSize=6930432 version=3.6.0
restored to restored/
I started a second etcd from the restored data directory on other ports and compared key counts by prefix with the live one:
/registry/secrets/ restored: 5 live: 5
/registry/namespaces/ restored: 13 live: 13
/registry/apiextensions.k8s.io/customresourcedefinitions/ restored: 7 live: 7
Everything the API server knows, about 7 MB here, fits in one file. The usual command line, from the Kubernetes etcd docs and not run here, since there was no etcdctl binary:
etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=... --key=... \
snapshot save /backup/etcd-$(date +%F-%H%M).db
etcdutl snapshot status /backup/etcd-....db
Restoring is a cluster-wide rewind. Stop the API servers, etcdutl snapshot restore into a fresh data directory on each member, start etcd on it, then start the API servers. Every object goes back to that revision, and anything created since is gone. Because Kubernetes clients cache resource versions, the etcd recovery docs say to restore with --bump-revision and --mark-compacted, so watchers re-list instead of trusting a revision that moved backwards. Controllers then reconcile against an older world, and Pods started after the snapshot become orphans the kubelets must clean up. It’s the tool for losing the control plane, not for undoing one bad deploy.
Two warnings. The snapshot contains every Secret, in plaintext unless encryption at rest is on, so protect it like a password vault. And on managed services (EKS, GKE, AKS) you don’t get etcd access at all. The provider protects the control plane. Your workloads are still yours to back up.
Velero: backups through the API
Velero backs up through the Kubernetes API instead of etcd, so it works on any cluster, managed or not, and can restore selectively:
velero schedule create nightly --schedule "0 2 * * *" \
--include-namespaces payments,orders --ttl 720h
velero backup create pre-upgrade --include-namespaces payments --wait
velero restore create --from-backup pre-upgrade --namespace-mappings payments:payments-restored
(From Velero’s docs, not run here.) A backup writes the selected objects as JSON to object storage (S3, GCS, Azure Blob), and handles volumes one of two ways: CSI volume snapshots, fast and crash-consistent, but stored by the cloud in the same region by default, or file-system backup with Kopia, copying volume contents to object storage, slower but portable across clouds. Restores can target another namespace or another cluster, which makes Velero a migration tool too.
What each disaster needs
| Disaster | Recovery |
|---|---|
| Deleted namespace or bad change | Velero restore of that namespace, or GitOps resync for stateless apps |
| Corrupted volume | Restore from a volume snapshot or app-level backup |
| Lost control plane (self-managed) | etcd snapshot restore, or rebuild and Velero restore |
| Lost region or account | New cluster from IaC + GitOps, data from cross-region backups |
GitOps isn’t a backup. A repository with every manifest, synced by Argo CD, rebuilds declared objects quickly, which makes clusters more disposable. It has no volume data, no runtime-generated Secrets, and no state controllers wrote. Rebuild from Git, then restore data from backups.
Databases deserve their own backups. A crash-consistent volume snapshot of a running database usually recovers, but point-in-time recovery comes from the database’s own tooling, which operators like CloudNativePG wire to object storage.
Making it real
- Store backups in another account and region, with object lock or versioning, so an attacker or a bad script in the cluster’s account can’t delete them.
- Back up before every upgrade and before risky migrations.
- Rehearse restores on a schedule: into a scratch cluster, then check the app actually works. Time it, since that’s your real RTO.
- Monitor backup jobs and alert on failures and on backups that are too old.
- Write the runbook while calm: which credentials, which commands, who decides.
About the video
The embed is Rawkode Academy’s “Kubernetes Disaster Recovery”, November 2025, 19 minutes, by David Flanagan. Going by its chapters and description, it frames backups as etcd state plus persistent volumes, the challenge of doing that across many clusters, then sets up Velero, takes a backup, simulates a disaster and restores. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the title, description and an uploaded English caption track. The page shows no audio-language flag. Viktor Farcic’s video in deeper goes deeper on Velero schedules and restores.
What was run: the snapshot was streamed from the lab cluster’s real etcd 3.6.6, checked and restored with etcd’s v3.6.6 snapshot library, and the restored copy was started as a separate etcd and compared key-by-prefix with the live one. All of that output is real. etcdctl’s command line, the restore procedure for a running control plane, and Velero are from the Kubernetes, etcd and Velero docs, checked 2026-11-29.
Where this fits
One cluster, backed up, is still one failure domain. Last: multi-tenancy and multi-cluster.
Check yourself
Your cluster is fully managed by Argo CD from Git. Why do you still need backups?
Git holds declared manifests only. It doesn't hold persistent volume data, Secrets created at runtime, objects controllers generate, or the cluster's exact state at a point in time. GitOps rebuilds the app definitions, and backups bring back the data.
On a managed cluster you can't reach etcd. How do you back up?
Through the API with a tool like Velero: back up namespaces and resources to object storage, and snapshot or copy PersistentVolumes via CSI snapshots or file-level backup. The provider protects the control plane's own etcd.
Why is restoring a full etcd snapshot a heavyweight operation?
It replaces every object with its state at snapshot time, including those created since. Controllers then reconcile against an older world, Pods that ran after the snapshot become orphaned, and the API servers must be stopped and restarted around the restore. It's for losing the control plane, not for fixing one bad deploy.
What makes an etcd snapshot file sensitive?
It contains every Secret in the cluster, unencrypted unless the API server uses encryption at rest. Treat snapshots like a credentials vault: encrypt them, restrict access, and keep them out of the cluster's own account.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.