Every Kubernetes object — Deployments, Services, Secrets, PersistentVolumeClaims — lives in one place: etcd. If the etcd cluster dies with no backup, you are not recovering workloads; you are rebuilding them from memory and whatever manifests happen to exist in git. Learning how to back up etcd is the single most valuable disaster recovery skill a cluster admin can pick up, and the mechanics take less than an hour.
This guide walks through the etcd snapshot save restore workflow end to end: how snapshots work, the exact etcdctl commands, where to keep snapshots so they survive a disaster, how to automate backups with a CronJob, and restore testing before you need one.
Why etcd Is the One Thing You Must Back Up
Kubernetes is stateless everywhere except etcd. The API server, scheduler, and controller manager all read and write cluster state through etcd; kubelet state rebuilds. One etcd snapshot captures your entire cluster: namespaces, RBAC bindings, ConfigMaps, Secrets (base64-encoded at rest unless you enabled encryption at rest — another reason for a proper secrets management strategy), and the last known state of every workload.
What a snapshot does not capture: container images (pull them again), persistent volume data (back up separately with Velero or storage-driver tools), and node-level configuration. Plan disaster recovery around that boundary; never treat an etcd snapshot as a complete cluster clone.
How etcd Snapshots Work
Since etcd v3, the cluster exposes built-in snapshots through the etcdctl CLI with ETCDCTL_API=3. A snapshot is a point-in-time copy of the keyspace: typically a few megabytes for small clusters, growing with object count and revision history. Snapshots are taken from a live member without stopping anything, and they are versioned: a snapshot only restores into the same major/minor etcd version that created it, so pin your etcd binaries in runbooks.
etcd also compacts old revisions automatically (or via --auto-compaction-retention), which keeps snapshot size in check. To back up etcd reliably, the flow is always the same: snapshot → verify → copy off-node → restore only when needed.
Back Up etcd With etcdctl Snapshot Commands
On a kubeadm control plane, the etcd certificates live under /etc/kubernetes/pki/etcd/. Run the snapshot command there:
ETCDCTL_API=3 etcdctl
--endpoints=https://127.0.0.1:2379
--cacert=/etc/kubernetes/pki/etcd/ca.crt
--cert=/etc/kubernetes/pki/etcd/server.crt
--key=/etc/kubernetes/pki/etcd/server.key
snapshot save /var/backups/etcd/snapshot-$(date +%F).db
A successful run prints a confirmation with the snapshot path. Never trust the exit code alone; verify the file immediately:
ETCDCTL_API=3 etcdctl
--endpoints=https://127.0.0.1:2379
--cacert=/etc/kubernetes/pki/etcd/ca.crt
--cert=/etc/kubernetes/pki/etcd/server.crt
--key=/etc/kubernetes/pki/etcd/server.key
snapshot status /var/backups/etcd/snapshot-$(date +%F).db --write-out=table
The status table shows the hash, revision, and total keys. If the hash reads zero or the file is missing, the backup failed. That is why verification belongs in the script, not in your memory. For managed clusters like EKS, GKE, or AKS, etcd snapshots happen behind the scenes, but control-plane recovery differs per cloud — check your provider’s docs.
Where to Store Snapshots (Off-Node Is Non-Negotiable)
A snapshot that exists only on its source node is not a backup: a disk failure, node rebuild, or region outage takes it with it. Copy every snapshot to at least one place outside the cluster:
- Object storage:
aws s3 cporrcloneto S3/GCS/R2 right after each snapshot. Version the bucket so a bad overwrite never destroys your last good copy. - Off-site host:
rsyncover SSH to a hardened backup host outside the cluster’s failure domain. - Retention: keep dailies for 7 days, weeklies for a month. etcd snapshots are small; storage is not the constraint, discipline is.
Encrypt snapshots at rest. They contain every Secret in the cluster. A bucket with plaintext etcd snapshots is a credentials leak waiting to happen, so use server-side encryption and, if you are careful, encrypt the file itself with age or gpg before upload.
Restore etcd From a Snapshot
Restoring is the part people skip practicing, which is why restores fail when they matter. The snapshot restore command rebuilds a data directory from the file; it does not touch a running cluster. On a single-node kubeadm control plane, the outline is:
# 1. Stop the static control-plane pods by moving their manifests
mkdir -p /etc/kubernetes/manifests.bak
mv /etc/kubernetes/manifests/etcd.yaml /etc/kubernetes/manifests.bak/
mv /etc/kubernetes/manifests/kube-apiserver.yaml /etc/kubernetes/manifests.bak/
# 2. Restore the snapshot into a fresh data directory
ETCDCTL_API=3 etcdctl snapshot restore /var/backups/etcd/snapshot-2026-10-24.db
--data-dir /var/lib/etcd-restore
# 3. Swap in the restored data directory
mv /var/lib/etcd /var/lib/etcd.old
mv /var/lib/etcd-restore /var/lib/etcd
chown -R etcd:etcd /var/lib/etcd # adjust to your distro's user
# 4. Bring the control plane back
mv /etc/kubernetes/manifests.bak/*.yaml /etc/kubernetes/manifests/
For multi-node etcd clusters, every member must restore from the same snapshot with a new initial-cluster configuration, or you rebuild the cluster with one restored member and re-add the others. The official etcd disaster recovery docs spell out both procedures; read them once for your exact etcd version before improvising.
Two gotchas that bite everyone once: the restore host must run the same etcd version that created the snapshot, and the API server comes back serving cluster state as of the snapshot. Anything created after the snapshot is gone from etcd’s view: workloads may still run on nodes, but their objects need re-applying. That is why backup frequency is a business decision, not a technical one.
Automate Backups With a Kubernetes CronJob
Manual snapshots rot. Schedule the backup with an etcd backup CronJob that mounts the etcd certificates and pushes snapshots to object storage. This pattern works for self-managed clusters; if you are still getting oriented with Kubernetes primitives, the CronJob below shows mounting host paths and secrets in practice:
apiVersion: batch/v1
kind: CronJob
metadata:
name: etcd-backup
namespace: kube-system
spec:
schedule: "0 2 * * *" # daily at 02:00
jobTemplate:
spec:
template:
spec:
nodeSelector:
node-role.kubernetes.io/control-plane: ""
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
restartPolicy: OnFailure
containers:
- name: backup
image: bitnami/etcd:3.5.12 # pin to YOUR etcd version
env:
- name: ETCDCTL_API
value: "3"
command:
- /bin/sh
- -c
- |
etcdctl --endpoints=https://127.0.0.1:2379
--cacert=/etc/kubernetes/pki/etcd/ca.crt
--cert=/etc/kubernetes/pki/etcd/server.crt
--key=/etc/kubernetes/pki/etcd/server.key
snapshot save /backup/snapshot-$(date +%F).db
&& etcdctl snapshot status /backup/snapshot-$(date +%F).db
&& aws s3 cp /backup/snapshot-$(date +%F).db s3://my-etcd-backups/
volumeMounts:
- name: etcd-certs
mountPath: /etc/kubernetes/pki/etcd
readOnly: true
- name: backup-dir
mountPath: /backup
volumes:
- name: etcd-certs
hostPath:
path: /etc/kubernetes/pki/etcd
type: Directory
- name: backup-dir
hostPath:
path: /var/backups/etcd
type: DirectoryOrCreate
Add alerting on CronJob failures: a backup job silently failing for three weeks is worse than no job at all, because it gives false confidence. A simple Prometheus alert on kube_job_failed for the etcd-backup job, or a dead-man’s-switch check that the S3 object is fresh, closes the gap. If you run autoscaling workloads alongside this, keep the backup job pinned to the control plane with the nodeSelector above so it never lands on an ephemeral worker.
Test the Restore Before You Need It
An untested backup is a rumor. Quarterly, spin up a throwaway single-node cluster (a cheap VM is fine), restore your latest snapshot, and confirm the objects are there:
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379
--cacert=/etc/kubernetes/pki/etcd/ca.crt
--cert=/etc/kubernetes/pki/etcd/server.crt
--key=/etc/kubernetes/pki/etcd/server.key
get / --prefix --keys-only | head -20
Document the exact restore steps your team ran, including the etcd version and how long the API server took to return. That document becomes your runbook, and the next person on call — paged at 3 a.m., not you at your desk — follows it instead of improvising.
Finally, fold etcd backups into your release safety net. Snapshot etcd before any risky control-plane change: cluster upgrades, risky rollout strategy changes, certificate rotations. A fresh snapshot turns a botched upgrade from a resume-generating event into a thirty-minute restore.
Back up etcd tonight if you have not yet: one snapshot command, one verification, one copy to object storage. The rest — automation, alerting, quarterly restore drills — turns a file on a disk into an actual Kubernetes disaster recovery backup plan.