ETCD — Part 2

Backup your ETCD cluster

Narendra Reddy
3 min readAug 6, 2022

All Kubernetes objects are stored on etcd. This file contains Kubernetes states and other essential data. In order to restore Kubernetes clusters in the event of a disaster, such as the loss of all control plane nodes, it is essential to routinely backup the etcd cluster data. We will discover how to take a backup of the ETCD cluster in this article.

Let’s create an ETCD cluster backup and put it in a location called /opt/etcd-backup.db.

Let’s look at the installed version of etcdctl.

ETCDCTL_API=3 etcdctl version

Let’s navigate to the Kubernetes manifest folder, which contains the etcd’s configuration information.

cd /etc/kubernetes/manifests

Let’s now list every configuration file included therein.

ls

Let’s examine the etcd.yaml file to determine all the necessary backup parameters.

cat etcd.yaml

Endpoint values and the absolute paths for cacert, cert, and key are required in order to take the backup. Let’s pass it as follows once we have all the values from the etcd.yaml file.

Note: We’ll run the member list command first, which displays a list of all the members, before running the command to test if it works or not.

ETCDCTL_API=3 etcdctl --endpoints 10.53.242.3:2379 \ —-cert=/etc/kubernetes/pki/etcd/server.crt \ —-key=/etc/kubernetes/pki/etcd/server.key \ —-cacert=/etc/kubernetes/pki/etcd/ca.crt \   member list

It is effective. It’s running smoothly.

Let’s take the backup in the directory /opt/etcd-backup.db

ETCDCTL_API=3 etcdctl --endpoints 10.53.242.3:2379 \—-cert=/etc/kubernetes/pki/etcd/server.crt \—-key=/etc/kubernetes/pki/etcd/server.key \—-cacert=/etc/kubernetes/pki/etcd/ca.crt \snapshot save /opt/etcd-backup.db

Let’s examine the status to determine whether the backup was successful or not.

ETCDCTL_API=3 etcdctl --endpoints 10.53.242.3:2379 \—-cert=/etc/kubernetes/pki/etcd/server.crt \—-key=/etc/kubernetes/pki/etcd/server.key \—-cacert=/etc/kubernetes/pki/etcd/ca.crt \snapshot status /opt/etcd-backup.db -w table

You can see that the backup was done perfectly.

--

--