هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
On a control-plane node of a kubeadm cluster:
Step by step
- Find the etcd settings (endpoint and certificate paths) in the static Pod manifest:
grep -E 'listen-client-urls|cert-file|key-file|trusted-ca-file|data-dir' /etc/kubernetes/manifests/etcd.yaml- Take the snapshot (the quick answer) and check it:
etcdutl snapshot status /backup/etcd-2026-11-19-0200.db -w table
+----------+----------+------------+------------+
HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
7d1e2c3a | 918273 | 1432 | 9.1 MB |
+----------+----------+------------+------------+- Protect the file — it contains every Secret of the cluster:
chmod 600 /backup/etcd-*.dbCopy it off the node (another server, object storage with encryption). A backup on the same disk dies with the node.
- Restore (the cluster goes back to the time of the snapshot). Restore into a new data folder, then point etcd to it:
etcdutl snapshot restore /backup/etcd-2026-11-19-0200.db --data-dir /var/lib/etcd-restored
sed -i 's#path: /var/lib/etcd$#path: /var/lib/etcd-restored#' /etc/kubernetes/manifests/etcd.yaml
crictl ps | grep etcdThe kubelet sees the changed manifest and restarts etcd with the restored data (wait 1–2 minutes). On a cluster with several control-plane nodes, restore on all members with the same snapshot and the --name/--initial-cluster options (see the full etcd guide).
- Automate — a daily snapshot with a systemd timer (or cron), keep 14 days, copy off the node:
#!/bin/bash
set -euo pipefail
f=/backup/etcd-$(date +%F-%H%M).db
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 "$f"
chmod 600 "$f"
find /backup -name 'etcd-*.db' -mtime +14 -delete- Other clusters:
- k3s:
k3s etcd-snapshot save(with embedded etcd); snapshots in/var/lib/rancher/k3s/server/db/snapshots/. - EKS / AKS / GKE: no etcd access — the provider runs it. Back up your resources and volumes with Velero, and keep all manifests in Git (GitOps = rebuild from Git).
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
context deadline exceeded | Wrong endpoint or certificates. | Take the values from etcd.yaml; use https://127.0.0.1:2379. |
etcdutl: command not found | Only etcdctl is installed. | Get etcdutl from the same etcd release (older guides use etcdctl snapshot restore). |
| etcd does not start after restore | The manifest still points to the old folder, or wrong owner/SELinux label. | Check hostPath and --data-dir; crictl logs of the etcd container. |
| API server errors for some minutes after restore | Components cache the old state. | Wait; restart kubelet on the nodes if Pods look wrong. |
| Snapshot file is tiny or empty | It was taken from a broken member or the disk was full. | etcdutl snapshot status; take it from a healthy member. |
| Secrets readable by anyone with the backup | Snapshots are not encrypted. | 600 rights, encrypted off-site storage, and encryption at rest in the cluster. |
Go further
- Command pages: etcdctl, crictl, kubectl.
- Next how-tos: Create a systemd timer, Copy files between servers, Create a Kubernetes Secret safely, Upgrade a kubeadm cluster, Back up Kubernetes with Velero.
- Learn it: CKA — Back up etcd, CKA — Restore etcd, CKS — Exam backup tips.
- Full guides: etcd, Velero, k3s.
- Practise: Lab: back up etcd, break the cluster, restore it.
1Why restore into a new data folder instead of the old one?
The old data stays as a fallback, and etcd starts clean from the snapshot.
2How do you back up a managed cluster (EKS/AKS/GKE) where you can not reach etcd?
Back up resources and volumes with Velero, and keep all manifests in Git.