top of page
Writer's pictureRafael Natali

Backing up an etcd cluster

Updated: Apr 25

All Kubernetes objects are stored on etcd. Periodically backing up the etcd cluster data is important to recover Kubernetes clusters under disaster scenarios, such as losing all control plane nodes. Otherwise, you will have to rebuild your cluster from scratch.


This article presents how to backup and restore etcd using the etcdctl snapshot command. and is part of a series of CKA-related articles here in the blog.




Built-in snapshot


Below is an example for taking a snapshot of the keyspace served by the endpoint http://10.0.1.101:2379 to the file snapshot.db:

ETCDCTL_API=3 etcdctl --endpoints http://10.0.1.101:2379 snapshot save snapshot.db

Verify the snapshot:

ETCDCTL_API=3 etcdctl --write-out=table snapshot status snapshot.db
+----------+----------+------------+------------+
|   HASH   | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
| 68ae77f5 |        2 |          5 |      20 kB |
+----------+----------+------------+------------+

Restoring an etcd cluster


etcd supports restoring from snapshots that are taken from an etcd process of the major.minor version. Restoring a version from a different patch version of etcd also is supported. A restore operation is employed to recover the data of a failed cluster.


The restore operation creates a temporary logical cluster in order to repopulate your data from that saved backup.


Here is an example:

ETCDCTL_API=3 etcdctl --endpoints http://10.0.1.101:2380 snapshot restore snapshot.db

References


24 views0 comments

Comments


bottom of page