Skip to content

How to Back Up and Restore etcd with etcdctl Snapshots

A practitioner guide to etcd backup and restore: locate your endpoints and certs, take a verified snapshot with etcdctl, automate it, and rebuild a kubeadm control plane with etcdutl.

If a kubeadm control plane loses etcd, it loses the entire cluster state — every Deployment, Secret, and object lives there and nowhere else. An etcd snapshot is the one backup that lets you rebuild that state on a fresh node, so if you are here to take a reliable snapshot and prove you can restore from it, you are in the right place. This guide shows you how to find your etcd endpoints and certificates, take a point-in-time snapshot with etcdctl snapshot save, verify it, automate it on a timer, and then restore it with etcdutl when a node is gone.

What you’ll accomplish

  • Take a consistent, point-in-time snapshot of a live etcd member without stopping the API server.
  • Verify the snapshot is intact before you trust it — an unverified backup is a guess.
  • Automate snapshots on a systemd timer so a fresh copy exists without anyone remembering to run one.
  • Rebuild etcd from a snapshot onto a new data directory and bring the control plane back up.
  • Know which failures the process actually protects against, and which it does not.

Prerequisites

  • etcd v3.5 or newer. Check the version the cluster ships with: kubectl -n kube-system exec etcd-<control-plane-node> -- etcd --version. The etcdutl binary used for restore is standard from 3.5 onward.
  • A kubeadm cluster with stacked etcd — etcd runs as a static Pod on each control-plane node, which is the default kubeadm layout. If you run external etcd (a dedicated etcd cluster outside kubeadm), the snapshot commands are identical but the certificate paths and the restart step differ; the manifest-repointing step does not apply. If you are still standing this up, deploy a kubeadm cluster with stacked etcd first.
  • ETCDCTL_API=3 in your environment. etcd v3.4+ defaults to the v3 API, but export it anyway so the flag names in this guide behave the way you expect.
  • Root or sudo on a control-plane node, plus read access to the etcd client certificates under /etc/kubernetes/pki/etcd/.
  • Enough free disk to hold the snapshot. A snapshot is roughly the size of the etcd database — check it with du -h /var/lib/etcd.

How it works

A snapshot is a consistent copy of etcd’s backing database at a single revision. etcdctl snapshot save opens a read transaction against a running member and streams the whole keyspace into one .db file, so the copy is internally consistent even while the API server keeps writing. You never stop etcd to take one.

etcd snapshot backup and restore data flow

Restore runs the opposite direction and it runs offline. etcdutl snapshot restore reads the .db file and writes a brand-new data directory with a fresh member and cluster identity — it never edits a live member in place. You then point etcd at that new directory and start it. Because restore rebuilds identity, restoring is a deliberate rebuild, not a hot rollback: you bring etcd down, restore, repoint, and bring it back.

Step-by-step

1. Locate your endpoints and certificates. kubeadm records everything the client needs in the etcd static Pod manifest. Read it to confirm the paths before you rely on them.

sudo grep -E 'listen-client-urls|trusted-ca-file|cert-file|key-file' \
  /etc/kubernetes/manifests/etcd.yaml

Expected output — the client URL and the three cert paths this guide uses:

- --cert-file=/etc/kubernetes/pki/etcd/server.crt
- --key-file=/etc/kubernetes/pki/etcd/server.key
- --listen-client-urls=https://127.0.0.1:2379,https://10.0.0.11:2379
- --trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt

2. Confirm you can talk to the member. Export the API version and check member health before you trust any backup taken through this path.

export ETCDCTL_API=3
sudo 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 \
  endpoint health

Success looks like this:

https://127.0.0.1:2379 is healthy: successfully committed proposal: took = 8.1ms

3. Take the snapshot. Same connection flags, plus a destination path. Name the file with a timestamp so successive runs never overwrite each other.

sudo 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/snap-$(date +%Y%m%d-%H%M%S).db

The success signal is an explicit “Snapshot saved” line:

{"level":"info","msg":"saved","path":"/var/backups/etcd/snap-20260720-030200.db"}
Snapshot saved at /var/backups/etcd/snap-20260720-030200.db

4. Verify the snapshot. A file on disk is not a backup until you have checked it. snapshot status reads the file’s own hash and metadata without touching the live cluster.

sudo etcdutl snapshot status \
  /var/backups/etcd/snap-20260720-030200.db --write-out=table

You want a non-zero revision and key count:

+----------+----------+------------+------------+
|   HASH   | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
| 3f2a1b90 |   918342 |       1487 |      21 MB |
+----------+----------+------------+------------+

A REVISION of 0 or a read error means the file is truncated or corrupt — discard it and take another. (etcdctl snapshot status still works in 3.5 but prints a deprecation notice; etcdutl is the current home for offline snapshot operations.)

5. Move the snapshot off the node. A snapshot that only exists on the machine you are trying to recover is not disaster recovery. Copy it somewhere independent — object storage, an NFS export, another host:

aws s3 cp /var/backups/etcd/snap-20260720-030200.db \
  s3://my-etcd-backups/$(hostname)/

A completed upload prints the source-to-destination line:

upload: ./snap-20260720-030200.db to s3://my-etcd-backups/cp-1/snap-20260720-030200.db

Substitute your own transport; the requirement is only that the copy survives the loss of this node.

6. Automate it with a systemd timer. Manual snapshots are the ones nobody takes. Wrap steps 3 through 5 in a small script at /usr/local/sbin/etcd-snapshot.sh, then create a unit and a timer. The service:

# /etc/systemd/system/etcd-snapshot.service
[Unit]
Description=Take and verify an etcd snapshot

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/etcd-snapshot.sh

The timer that fires it every six hours:

# /etc/systemd/system/etcd-snapshot.timer
[Unit]
Description=Run etcd-snapshot four times a day

[Timer]
OnCalendar=00/6:00:00
Persistent=true

[Install]
WantedBy=timers.target

Enable it and confirm it is scheduled:

sudo systemctl daemon-reload
sudo systemctl enable --now etcd-snapshot.timer
systemctl list-timers etcd-snapshot.timer

Expected — a concrete next run time, not a blank:

NEXT                        LEFT       UNIT                 ACTIVATES
2026-07-20 06:00:00 UTC     2h 58min   etcd-snapshot.timer  etcd-snapshot.service

Have the script prune old snapshots (for example find /var/backups/etcd -name 'snap-*.db' -mtime +7 -delete) so the timer does not fill the disk.

7. Restore onto a new data directory. This is the recovery path, run on the control-plane node you are rebuilding. First move the old data aside and stop the running member by moving its manifest out of the way — kubelet stops any static Pod whose manifest leaves /etc/kubernetes/manifests/:

sudo mv /etc/kubernetes/manifests/etcd.yaml /root/etcd.yaml.bak
sudo mv /var/lib/etcd /var/lib/etcd.old

Now restore the snapshot into a fresh directory. Use etcdutl — plain etcdctl snapshot restore is deprecated in 3.5 and prints a warning steering you here:

sudo etcdutl snapshot restore \
  /var/backups/etcd/snap-20260720-030200.db \
  --data-dir /var/lib/etcd

The success signal names the restored directory:

{"level":"info","msg":"restored snapshot","path":"/var/backups/etcd/snap-20260720-030200.db","data-dir":"/var/lib/etcd"}

8. Repoint the manifest and restart etcd. Move the manifest back so kubelet starts a new etcd Pod against the restored data directory:

sudo mv /root/etcd.yaml.bak /etc/kubernetes/manifests/etcd.yaml

kubelet notices the manifest within a few seconds and starts the Pod. Watch it come up:

sudo crictl ps --name etcd

You are looking for an etcd container in Running state with a recent start time. Once etcd is healthy, the API server reconnects on its own.

Validate it works

Restore is not done until the cluster answers. Check etcd health first, then the Kubernetes API:

export ETCDCTL_API=3
sudo 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 \
  endpoint status --write-out=table
+------------------------+------------------+---------+---------+-----------+
|        ENDPOINT        |        ID        | VERSION | DB SIZE | IS LEADER |
+------------------------+------------------+---------+---------+-----------+
| https://127.0.0.1:2379 | ade9c7f2a1b4e6d0 |   3.5.9 |   21 MB |      true |
+------------------------+------------------+---------+---------+-----------+

Then confirm the objects you expected are back:

kubectl get nodes
kubectl get pods -A

Every node should report Ready and your workloads should be listed. If a Deployment you know existed at snapshot time is present, the restore carried real state.

Troubleshooting

  • context deadline exceeded on save. Almost always wrong endpoints or certs. Confirm the URL from step 1 and that you passed --cacert, --cert, and --key — a v3 client with no TLS flags will time out against a kubeadm member that only speaks HTTPS.
  • permission denied reading a certificate. The etcd keys under /etc/kubernetes/pki/etcd/ are root-owned by design. Run the command with sudo; do not loosen the file permissions to work around it.
  • data-dir already exists on restore. etcdutl refuses to write into a populated directory so it never clobbers good data. Move the existing /var/lib/etcd aside (as in step 7) or restore into a new path, then repoint.
  • Member ID or cluster ID mismatch after restore. Restore mints a new cluster identity. On a single stacked member this is fine, but if other control-plane nodes still hold the old identity they will reject the restored member. For multi-member recovery, restore one member, then reset and rejoin the others rather than restoring each independently.
  • Revision went backward and controllers act confused. A snapshot is a point in time; restoring rolls the revision back to that moment, so anything created after the snapshot is gone and some controllers re-reconcile loudly. This is expected — it is the cost of a point-in-time restore, and the reason snapshot frequency matters.

When this is the wrong approach

etcd snapshots protect the cluster’s own state, and only where you control etcd. On managed Kubernetes — EKS, GKE, AKS — the provider owns etcd, you cannot reach it, and control-plane recovery is their responsibility, not a snapshot you take. There, this whole procedure does not apply.

This also is not application backup. etcd holds Kubernetes objects, not your PersistentVolume data, databases, or object storage. To protect workloads and their volumes at the application level, reach for a tool built for it — Velero for Kubernetes disaster recovery and restore covers backing up namespaces and volumes, which etcd snapshots deliberately do not. Run both: etcd snapshots for the control plane, Velero for the workloads.

For the exact flags and certificate details on your version, keep the official references open: etcd documentation and the Kubernetes guide to operating etcd for Kubernetes.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.