Skip to main content
RunBook Academy

KubernetesLXVIII · etcd Backupetcd backup

Why back up etcd — the failure modes only snapshots cover

Advanced⏱ ~16 minetcdctl

What you'll learn

  • Identify the failure modes only etcd snapshots cover
  • Distinguish etcd snapshot from application-level backup
  • Reason about what a snapshot protects and what it does not
  • Plan a backup strategy that covers the right threats

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

etcd snapshots are the cluster’s source of truth, taken off-cluster for safe storage and used to recover from the class of failures that affect the cluster’s state itself. They are not application backups; they are control-plane backups. This lesson walks what they cover, what they do not, and the failure modes that make them a non-negotiable operational discipline.

What etcd snapshots cover

An etcd snapshot is a consistent point-in-time copy of every API object the cluster records:

flowchart LR
    E[etcd db file] -->|snapshot| S[snapshot file]
    S -->|restore on new cluster| R[new cluster's state]
    S -->|store off-cluster| O[off-cluster storage]
    O -->|recovery target| R

The objects that are covered:

  • Workload definitions. Deployments, StatefulSets, DaemonSets, Jobs, CronJobs, and their revision histories.
  • Configuration. ConfigMaps, ResourceQuotas, LimitRanges, HPAs, PodDisruptionBudgets.
  • Service identity. Services, Ingresses, NetworkPolicies, EndpointSlices.
  • Access control. Roles, ClusterRoles, RoleBindings, ClusterRoleBindings, ServiceAccounts (the SA objects and the projected tokens’ stored halves).
  • Stateful definitions. PersistentVolumeClaims, StorageClasses (cluster-scoped), CustomResourceDefinitions and their instances.
  • Cluster state. Nodes (their objects in etcd), leases (rebuilt), events (subject to GC), audit log (if configured to write through etcd).

What is not in an etcd snapshot:

  • Application data in PVCs. The PVC object is in etcd; the bytes written by the application are in the storage backend (CSI driver, NFS, Ceph, etc.).
  • Container logs. Container logs are in /var/log/pods/... on the nodes; etcd has only the Event object that triggered them.
  • Container runtime cache. The running state of containers is in the kubelet’s local cache.
  • Real-time metrics. Cluster metrics are in Prometheus; the snapshot has only the metric exporter objects.

Failure modes an etcd snapshot recovers

Accidental deletion of cluster-scoped objects

A kubectl delete of a Namespace, a CRD, or an entire RBAC structure can tear down dozens of objects in seconds. The git history of the manifests helps re-create, but the runtime state (ReplicaSets’ replicas, status fields, controller-revision hashes) is lost. An etcd snapshot that pre-dates the deletion restores the cluster’s state exactly as it was.

Corruption of etcd data

A bbolt file can become corrupt (LXVI-03 walked the mechanism). The corrupt member can be wiped and re-added; but if multiple members’ data is corrupt, the cluster cannot recover without a snapshot restore.

Failed upgrade or RBAC restructure

A Kubernetes upgrade that goes wrong can leave the cluster in a state where nodes cannot register, RBAC bindings are missing, or controllers crash. A snapshot pre-upgrade is the rollback primitive.

Disaster recovery across a region or site

A regional failure that takes the data centre down requires rebuilding the cluster on new infrastructure. The etcd snapshot from before the failure is the seed for the new cluster’s state.

Security incident response

A cluster compromised by a malicious operator account or a leaked ServiceAccount token can have state owned by the attacker. A snapshot pre-incident is the recovery state; the response sequence is restore the snapshot, revoke all credentials, change all Secrets, then re-issue access.

Failure modes an etcd snapshot does NOT recover

FailureCovered?Reason
Application data corruption in PVCsNoApplication data lives in CSI; etcd has only the PVC object
Pod-level log lossNoLogs are in /var/log/pods on the node
Container runtime cache lossNoRestarted via the Pod spec in etcd
Single Pod deletionEventuallyPods are re-created by their controller if the spec is intact
Bad deployment rolloutNo — same cluster stateRoll back via the Deployment’s history, not via snapshot
Compromised image registryMaybeIf the image is referenced by digest in a Deployment that’s in the snapshot, restore brings the reference back; the registry still serves the bad image

A snapshot does not replace a workload backup. It is a control-plane backup.

The backup-and-restore layered model

flowchart TB
    L1["Layer 1: etcd snapshot (control plane)"] --> R1["etcd snapshot restore"]
    L2["Layer 2: workload backup"] --> R2["CSI snapshots, database dumps"]
    L3["Layer 3: Git desired state"] --> R3["git reapply"]

A complete backup strategy combines all three layers:

  • Layer 1: etcd snapshot covers API state.
  • Layer 2: workload backup (Velero, database dumps) covers the bytes applications wrote into PVCs.
  • Layer 3: Git holds the desired state; a complete restore would reapply it.

In a complete DR scenario, the recovery sequence is:

  1. Restore etcd from snapshot (control-plane state).
  2. Bring up the storage platform (so PVs can bind PVCs).
  3. Restore workload bytes from workload backups.
  4. Re-apply Git for any state that drifted from snapshot.
  5. Validate cluster and workloads.

What a backup protects against

What an etcd snapshot is for:

  • Recovery from cluster corruption.
  • Recovery from accidental mass deletion.
  • DR across site or region failure.
  • Compliance requirement for point-in-time cluster state.
  • Sandbox restores for testing (“give me a copy of last week’s cluster”).

What a snapshot is not for:

  • Real-time replication (the cluster itself replicates writes; snapshots are point-in-time).
  • Selective object recovery (a snapshot is whole-cluster; restore is whole-cluster).
  • Workload data recovery (PVC bytes are separate).
Read-only / Safe
$ etcdctl snapshot save /backup/etcd-snapshot-$(date +%Y%m%d-%H%M).db
"saved snapshot to /backup/etcd-snapshot-20260816-1200.db"

The “I don’t need backups” anti-pattern

A common anti-pattern: “we have a high-availability 3-member etcd, so we don’t need off-cluster backups”. The HA covers availability — the cluster keeps serving writes. Backup covers data integrity — the cluster’s state can be recovered after corruption or human error.

These are distinct properties:

  • HA without backup. A cluster survives host loss; if all three hosts are corrupted, the cluster’s state is gone.
  • Backup without HA. Snapshots can be restored to a new cluster, but during a member loss the cluster is offline (in the case of a 1-member setup).

Both are necessary.

The matrix of recovery scenarios

ScenarioRecovery pathSnapshot required?
1 of 3 members corruptWipe and rejoinYes, if multiple members corrupt
2 of 3 members corruptRestore from snapshotYes
All members corrupt or lostRestore to new clusterYes
Accidental kubectl delete namespaceRestore from snapshotYes
Buggy CRD removalRestore from snapshotYes
Pod failureRe-create from specNo
Node failureNew node joinsNo
PVC backend failureCSI-side recoveryNo
Cluster loses quorumRestore to new clusterYes
Region failureRestore to new regionYes

The pattern: anything that affects etcd’s stored state needs a snapshot.

Operational placement of the snapshot

A production snapshot plan:

gantt
    title etcd snapshot cadence
    dateFormat HH:mm
    axisFormat %H:%M
    section Hourly
    Snapshot to off-cluster :a1, 00:00, 5m
    Verify snapshot integrity :a2, after a1, 1m
    section Daily
    Upload to object storage :b1, 01:00, 5m
    section Weekly
    Test restore on isolated host :c1, Sat 02:00, 60m
    section Monthly
    Audit snapshot chain integrity :d1, 1st of month, 5m

The cadence:

  • Hourly: snapshot to a known path on a control-plane host.
  • Daily: off-cluster transfer (object storage, second region).
  • Weekly: restore drill.
  • Monthly: chain integrity audit.

This cadence covers the typical recovery scenarios within the hour they occurred, with off-cluster copies surviving site failure.

Quiz

Knowledge check · 4 questions

  1. Q1. Does an etcd snapshot back up the data inside a PersistentVolumeClaim?

  2. Q2. A 3-member HA etcd cluster needs no off-cluster backups because the cluster itself can survive any single member failure.

  3. Q3. Your team uses an internal script that runs `kubectl delete -f` to rotate a namespace. Today's rotation deleted the namespace `prod-app`, along with all 14 production Deployments, 3 StatefulSets (with PVCs), and 50 ConfigMaps. Diagnose and remediate.

    Cluster state pre-deletion included the namespace `prod-app` with 14 Deployments, 3 StatefulSets (each with a 100 GiB PVC backed by Retain), and 50 ConfigMaps. The script fired against the wrong namespace due to a kubeconfig mistake. The cluster is otherwise healthy. Snapshot cadence is hourly; the most recent snapshot is 35 minutes old.

  4. Q4. Name three recovery layers that together cover a complete Kubernetes cluster restore.

Passing score: 75%. Answers are checked in this browser.

Production discipline

  • Snapshot hourly. Storage is cheap; data loss is expensive. An hour-old snapshot is the worst case.
  • Snapshot off-cluster. A snapshot on the same host as the etcd member is a snapshot that is lost with the host.
  • Test the restore quarterly. A snapshot that has never been restored is a snapshot you don’t know how to restore.
  • Cover workload data separately. Etc snapshot does not cover PVC bytes; Velero or CSI snapshots cover that.
  • Treat the snapshot’s staleness as a known lost window. Document it in the post-mortem; recover the lost window from Git or workload backups where possible.

Etcd backup is the foundation that every DR scenario relies on. Operating it well is what makes the rest of the cluster’s incident response possible.