Backup & Restore data in Kubernetes

  1. Backing up ‘etcd’ data is done using etcd command line tool: etcdctl
ETCDCTL_API=3 etcdctl --endpoints $ENDPOINT snapshot save <filename>
ETCDCTL_API=3 etcdctl snapshot restore <filename>
ETCDCTL_API=3 etcdctl get cluster.name \
> --endpoints=https://10.0.1.101:2379 \
> --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
> --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
> --key=/home/cloud_user/etcd-certs/etcd-server.key
cluster.name
beebox
The returned value for the Cluster.name is beebox
ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
> --endpoints=https://10.0.1.101:2379 \
> --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
> --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
> --key=/home/cloud_user/etcd-certs/etcd-server.key
sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
> --initial-cluster etcd-restore=https://10.0.1.101:2380 \
> --initial-advertise-peer-urls https://10.0.1.101:2380 \
> --name etcd-restore \
> --data-dir /var/lib/etcd
sudo chown -R etcd:etcd /var/lib/etcd
sudo systemctl start etcd
ETCDCTL_API=3 etcdctl get cluster.name \
> --endpoints=https://10.0.1.101:2379 \
> --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
> --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
> --key=/home/cloud_user/etcd-certs/etcd-server.key
cluster.name
beebox

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store