# Backup kubernetes cluster

**URL:** <https://discuss.kubernetes.io/t/backup-kubernetes-cluster/16859>\
**Category:** General Discussions\
**Created:** [July 27, 2021, 6:15am UTC](https://discuss.kubernetes.io/t/backup-kubernetes-cluster/16859 "2021-07-27T06:15:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avnish\_Singh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/avnish_singh/32/8234_2.png) [@Avnish\_Singh](https://discuss.kubernetes.io/u/Avnish_Singh)\
**Post date:** [July 27, 2021, 6:15am UTC](https://discuss.kubernetes.io/t/backup-kubernetes-cluster/16859/1 "2021-07-27T06:15:19Z")

</div>

Kubernetes version:1.21.0  
Cloud being used: bare-metal  
Installation method:kubeadm  
Host OS: centos 7  
CNI and version: Flannel v 0.3.1  
CRI and version: Docker v 20.10.7

How to backup etcd in my current setup?

The etcdcl command gives and error:  
-bash: etcdctl: command not found

The etcdctl command doesn’t work in my current setup please help.  
Thanks

---

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [July 27, 2021, 7:12am UTC](https://discuss.kubernetes.io/t/backup-kubernetes-cluster/16859/2 "2021-07-27T07:12:39Z")

</div>

On CentOS, you have to get it yourself and it’s not packaged separately in the github repo.

```nohighlight
[root@3cdac2ffafa9 ~]# curl -sLO https://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-linux-amd64.tar.gz

[root@3cdac2ffafa9 ~]# tar -xzvf etcd-v3.5.0-linux-amd64.tar.gz 
etcd-v3.5.0-linux-amd64/
...truncated output ...
etcd-v3.5.0-linux-amd64/etcdutl
etcd-v3.5.0-linux-amd64/etcdctl
etcd-v3.5.0-linux-amd64/etcd

[root@3cdac2ffafa9 ~]# mv etcd-v3.5.0-linux-amd64/etcdctl /sbin/etcdctl

[root@3cdac2ffafa9 ~]# etcdctl version
etcdctl version: 3.5.0
API version: 3.5

```

After this, you need to set it up to talk to your cluster’s etcd. Which is not intuitive…

Looking at the steps I have for [setting up Ubuntu with kubeadm](https://github.com/scalabledelivery/kubernetes/blob/master/playbooks/kubeadm/setup.yaml#L139-L161), you need something like this in `~/.bashrc`.

```nohighlight
export ETCDCTL_API=3
export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt
export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key

```

I don’t know if the paths will be different on Cent OS or not, but after you get it working you can run:

```nohighlight
$ etcdctl snapshot save <backup-file-location>
$ etcdctl snapshot restore <backup-file-location>

```

More information on etcd related specifically to Kubernetes can be found here:

> **[Operating etcd clusters for Kubernetes](https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/)**
>
> etcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.
> If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for those data.
> You can find in-depth...
