Sub topic 15
Choosing between etcd snapshots and Velero
This chapter assumes you can run kubectl, have SSH access to a control plane node, and have already seen both tools: etcdctl snapshot save and velero backup create. The goal is to decide which tool covers which failure, and when to run both.
What each tool captures
An etcd snapshot is a copy of the whole key-value store behind the API server. It holds every object in the cluster, including Secrets, RBAC rules, and CRDs. It does not hold the contents of persistent volumes.
Velero reads objects through the Kubernetes API and writes them to object storage as a backup. It can also back up volume data, using CSI snapshots or file system backup. It works at the level of namespaces, labels, and resource types.
| Question | etcd snapshot | Velero |
|---|---|---|
| What does it save? | All cluster state, as raw etcd data | Selected API objects, plus optional volume data |
| Scope | Whole cluster only | Namespace, label, or resource type |
| Volume data | No | Yes, through CSI snapshots or file system backup |
| Restore target | The same cluster, or a rebuilt control plane | The same cluster or a different one |
| Needs node access | Yes, on a control plane node | No, only API access and a bucket |
| Managed clusters | Usually unavailable, because the provider owns etcd | Works |
Matching tool to failure
The failure you expect should drive the choice.
- A developer deletes a namespace or a Deployment. Use Velero. Restoring a whole etcd snapshot to recover one namespace would roll back every other change made since the snapshot.
- Control plane loss, or etcd corruption. Use an etcd snapshot. It brings back the API state exactly, including objects Velero might skip.
- Lost or corrupted volume data. Use Velero with volume backups. etcd never held that data.
- Moving a workload to another cluster. Use Velero, with namespace mappings if needed.
- Total loss of the cluster and its nodes. You need both. Rebuild the control plane and restore etcd, or build a new cluster and restore workloads with Velero. Then restore the volume data.
Running both
For a self-managed cluster, a common setup combines them:
- A scheduled etcd snapshot, copied off the node, protects the control plane.
- Scheduled Velero backups of application namespaces protect workloads and data, with a TTL that matches how long you need to go back.
The two overlap on object definitions, which is acceptable. Each covers a gap the other leaves.
Common mistakes
- Relying on etcd alone for stateful apps. The snapshot restores the PersistentVolumeClaim objects, but the data behind them is gone.
- Relying on Velero alone for a self-managed control plane. Velero needs a working API server and its own deployment. If the control plane is gone, you must rebuild it first.
- Keeping backups only in the failure domain. Snapshots on the node's own disk, or a bucket in the same account that an attacker can delete, do not survive the failures you are protecting against.
- Assuming a managed service gives you etcd access. On many managed offerings, Velero is the only option you control.
Exercise
A cluster runs a stateful database in the namespace billing. Someone runs kubectl delete namespace billing by mistake, and the control plane is otherwise healthy. Which tool do you use, and why not the other?
Show answer
Use Velero, restoring the billing namespace from a backup that included volume data (CSI snapshots or file system backup). An etcd restore would roll back the entire cluster to the snapshot time, losing unrelated changes, and it would not recover the database's volume contents anyway.
Exercise
Your team uses a managed Kubernetes service where you cannot reach etcd. Which of the two tools can you use, and what must you configure so volume data is included?
Show answer
Velero is the only option, since etcd belongs to the provider. To include volume data, use CSI snapshots, or enable the node agent and file system backup (for example with --default-volumes-to-fs-backup).