Score:1

How to spin up a ETCD docker container and restore a backup obtained from a kubernetes ETCD Cluster node?

bw flag

I am trying to spin up a ETCD node in docker and restore a backup obtained from the Kubernetes Cluster node.

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379  --user=root:'root' snapshot save snapshot.db

I have obtained the snapshot and have it downloaded locally. How could i restore onto a already spinned up etcd node?

The following command was used to spin up the container.I have mounted a data volume.

docker run -d --restart always \
  -p 2379:2379 \
  -p 2380:2380 \
  --volume=etcd-volume:/etcd-data \
  --name etcd gcr.io/etcd-development/etcd:latest \
  /usr/local/bin/etcd \
  --data-dir=/etcd-data --name etcd \
  --initial-advertise-peer-urls http://127.0.0.1:2380 --listen-peer-urls 
  http://0.0.0.0:2380 \
  --advertise-client-urls http://127.0.0.1:2379 --listen-client-urls http://0.0.0.0:2379 \
  --initial-cluster etcd=http://127.0.0.1:2380

Then I tried to restore it using the following.

ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
  --name m1 \
  --initial-cluster m1=http://127.0.0.1:2379 \
  --initial-cluster-token etcd-cluster \
  --initial-advertise-peer-urls http://127.0.0.1:2379 \
  --data-dir /var/lib/docker/volumes/etcd-volume

Both the ETCD cluster and docker are on two different VMs. I tried to execute the above command from the local machine as etcdctl tool has to be installed in docker to execute that command. The restoration has not happened. I just need the keys to be copied onto the new. Any suggestion on how I could do it?

SYN avatar
hk flag
SYN
Is there an error? What does the snapshot restore tells you?
Anjula Paulus avatar
bw flag
I have done a small library implementation to copy and insert ETCD keys from one node to another in golang. https://github.com/anjulapaulus/etcd-replicator
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.