Version note: examples use the Kubernetes v1.35 documentation snapshot, not necessarily the newest release. Check current support and component compatibility. These commands were not tested on a live cluster.
What this guide covers
etcd stores Kubernetes cluster state, including resource definitions and Secret data. An etcd snapshot can help recover that state, but it does not back up files inside application volumes.
Before you start
This example assumes kubeadm-managed local etcd and administrative access to the control-plane host. Use etcdctl and etcdutl versions compatible with the installed etcd version. Protect snapshots like credentials.
Step 1: Check the existing configuration
Read /etc/kubernetes/manifests/etcd.yaml without editing it. Locate the data directory, endpoint and certificate files. This kubeadm example shows the directory setting used when creating a cluster:
apiVersion: kubeadm.k8s.io/v1beta4
kind: ClusterConfiguration
kubernetesVersion: v1.35.10
etcd:
local:
dataDir: /var/lib/etcd
Do not apply it to move a running etcd member. Do not leave backup YAML files in the watched manifests directory.
Step 2: Save and inspect a snapshot
On the control-plane host, run:
sudo install -d -m 0700 /var/backups/kubernetes
sudo etcdctl \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/healthcheck-client.crt \
--key=/etc/kubernetes/pki/etcd/healthcheck-client.key \
snapshot save /var/backups/kubernetes/etcd-snapshot.db
sudo etcdutl snapshot status /var/backups/kubernetes/etcd-snapshot.db --write-out=table
Use a new filename for each backup and check the command output. Store protected copies off the host so a disk failure does not destroy both cluster and backup.
Step 3: Test recovery separately
Follow the version-matched Kubernetes and etcd recovery procedure on isolated infrastructure. Restore into a new directory, with the correct member identity and documented revision handling. Do not restore over a live member merely to test a backup.
Step 4: Back up application data as well
Back up persistent volumes and application databases using their own consistent-backup procedures. Record the Kubernetes, etcd and application versions needed for recovery.
Check the result
A snapshot status or checksum is not proof of recovery. Test that a restored control plane works and expected resources exist. Record how old the recoverable data is and how long recovery takes.
Conversation
0 commentsNo comments yet. Start the conversation below.