CKA — etcd Snapshot Save

less than 1 minute read

Taking an etcd Backup

The etcdctl snapshot save command creates a point-in-time backup of all etcd data.

Snapshot Save Command

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 /opt/etcd-backup.db

Required Flags

Flag Purpose Where to Find
–endpoints etcd server URL etcd.yaml: –listen-client-urls
–cacert CA certificate etcd.yaml: –trusted-ca-file
–cert Server/client certificate etcd.yaml: –cert-file
–key Server/client private key etcd.yaml: –key-file

Finding Certificate Paths from etcd Manifest

# Quick way to get all cert paths
cat /etc/kubernetes/manifests/etcd.yaml | grep -E "cert-file|key-file|trusted-ca"

Using Environment Variables

To avoid typing long commands repeatedly:

export ETCDCTL_API=3
export ETCD_CERTS="--cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key"

# Now commands are shorter
etcdctl --endpoints=https://127.0.0.1:2379 $ETCD_CERTS snapshot save /opt/backup.db

Backup Storage Locations

Store backups in a safe location:

Location Use Case
/opt/etcd-backup.db Exam scenarios (local)
/backup/etcd/ Production (dedicated backup volume)
S3/GCS bucket Cloud production (offsite backup)

Exam tip: The exam question will specify where to save the backup. Read the path carefully and use the exact location.


Next: etcd Snapshot Restore ->

Updated: