etcdctl --endpoints=<url> --cacert=<ca> --cert=<cert> --key=<key> snapshot save
etcdctl --endpoints=<url> --cacert=<ca> --cert=<cert> --key=<key> snapshot save <file>
Risk: Safe
What it does
Saves a snapshot of the running etcd: a photocopy of the order book. Without the certificate flags it waits forever.
When to use it
On a schedule, and always before an upgrade or a risky change. Copy the file off the node.
Example
$ 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 /opt/backup.dbOn the control-plane node: save the whole cluster to /opt/backup.db.
$ kubectl -n kube-system exec etcd-dev-control-plane -- 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/lib/etcd/backup.dbOn kind: the nodes have no etcdctl, so run it in the etcd pod.
Learn it in: etcd backup and restore · Official docs