#1.备份
ETCDCTL_API=3 etcdctl snapshot save snapshot.db
恢复
#2.查看备份状态
ETCDCTL_API=3 etcdctl snapshot status snapshot.db -w=table
#3. 还原快照
kubectl cp /root/temp/snapshot.db -n ingress-apisix apisix-etcd-0:/tmp/
kubectl cp /root/temp/snapshot.db -n ingress-apisix apisix-etcd-1:/tmp/
kubectl cp /root/temp/snapshot.db -n ingress-apisix apisix-etcd-2:/tmp/
# apisix-etcd-0
kubectl exec -it -n ingress-apisix apisix-etcd-0 -- bash
cd /tmp
rm -rf /bitnami/etcd/data/*
ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
--name apisix-etcd-0 \
--data-dir="/bitnami/etcd/data" \
--initial-cluster apisix-etcd-0=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-1=http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-2=http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380 \
--initial-advertise-peer-urls http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380
# apisix-etcd-1
kubectl exec -it -n ingress-apisix apisix-etcd-1 -- bash
cd /tmp
rm -rf /bitnami/etcd/data/*
ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
--name apisix-etcd-1 \
--data-dir="/bitnami/etcd/data" \
--initial-cluster apisix-etcd-0=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-1=http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-2=http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380 \
--initial-advertise-peer-urls http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380
# apisix-etcd-2
kubectl exec -it -n ingress-apisix apisix-etcd-2 -- bash
cd /tmp
rm -rf /bitnami/etcd/data/*
ETCDCTL_API=3 etcdctl snapshot restore snapshot.db \
--name apisix-etcd-2 \
--data-dir="/bitnami/etcd/data" \
--initial-cluster apisix-etcd-0=http://apisix-etcd-0.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-1=http://apisix-etcd-1.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380,apisix-etcd-2=http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380 \
--initial-advertise-peer-urls http://apisix-etcd-2.apisix-etcd-headless.ingress-apisix.svc.cluster.local:2380