备份还原ETCD
ETCD定期备份
1、查看ETCD状态
ETCDCTL_API=3 /opt/etcd/bin/etcdctl \
--cacert=/opt/etcd/ssl/ca.pem \
--cert=/opt/etcd/ssl/server.pem \
--key=/opt/etcd/ssl/server-key.pem \
--endpoints="https://172.17.35.60:2379" \
endpoint health --write-out=table
2、备份ETCD
vi /opt/etcd/bin/etcdctl_backup.sh
#!/bin/bash
ETCDCTL_API=3 /opt/etcd/bin/etcdctl \
--cacert=/opt/etcd/ssl/ca.pem \
--cert=/opt/etcd/ssl/server.pem \
--key=/opt/etcd/ssl/server-key.pem \
--endpoints="https://172.17.35.60:2379" \
snapshot save /opt/etcd/backup/etcd-snapshot-$(date +%F-%H-%M).db
crontal -l
*/10 * * * * sh /opt/etcd/bin/etcdctl_backup.sh
3、还原ETCD
systemctl stop etcd
ETCDCTL_API=3 /opt/etcd/bin/etcdutl snapshot restore /opt/etcd/backup/etcd-snapshot-2023-05-07-10-14.db --data-dir=/opt/etcd/data
systemctl start etcd