Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Kubernetes cluster backup and restore using “etcdctl” tool

What is etcd?
etcd is a distributed reliable key-value store for the most critical data of a distributed system, with a focus on being:

  • Simple: well-defined, user-facing API (gRPC)
  • Secure: automatic TLS with optional client cert authentication
  • Fast: benchmarked 10,000 writes/sec
  • Reliable: properly distributed using Raft

etcd is written in Go and uses the Raft consensus algorithm to manage a highly-available replicated log.

etcd is used in production by many companies, and the development team stands behind it in critical deployment scenarios, where etcd is frequently teamed with applications such as Kubernetes, locksmith, vulcand, Doorman, and many others. Reliability is further ensured by rigorous testing.

Reference
https://github.com/etcd-io/etcd

What is etcdctl
etcdctl is a command line client for etcd.

The v3 API is used by default on master branch. For the v2 API, make sure to set environment variable ETCDCTL_API=2. If using released versions earlier than v3.4, set ETCDCTL_API=3 to use v3 API.

Reference
https://github.com/etcd-io/etcd/tree/master/etcdctl

Install etcdctl tool and Taking Backup

Verify Backup

By the way if you not sure about values used in above command then you can check values from your /etc/kubernetes/manifests/etcd.yaml file.
Let’s confirm status of our backup using,

ETCDCTL_API=3 etcdctl --endpoints https://172.17.0.9:2379 snapshot status /tmp/snapshot-backup.db

How to Restore Cluster from backup?


Now, update values in /etc/kubernetes/manifests/etcd.yaml to use our restored data-dir. To restore cluster using etcdctl tool.\

Rajesh Kumar
Follow me