#下载的命令放到/usr/local/bin
https://github.com/coreos/etcd/releases/download/v3.5.3/etcd-v3.5.3-linux-amd64.tar.gz
# vim /root/.bashrc
alias etcdctl='ETCDCTL_API=3 etcdctl --endpoints=127.0.0.1:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key'
source /root/.bashrc
etcdctl get / --keys-only --prefix
[root@master0 share]# cat etcdbak.sh
#!/bin/bash -v
#Etcd time scripts backup auther
DATE=`date +%Y-%m-%d_%H-%M-%S`
NODE_IPS="192.168.201.60"
CACERT="/etc/kubernetes/pki/etcd/ca.crt"
CERT="/etc/kubernetes/pki/etcd/server.crt"
KEY="/etc/kubernetes/pki/etcd/server.key"
BACKUP_DIR="/data/backups/etcd-bak"
ETCDCTL_API=3 /usr/bin/etcdctl snapshot save ${BACKUP_DIR}/etcd-snapshot-${DATE}.db \
--cacert=${CACERT} \
--cert=${CERT} \
--key=${KEY} \
--endpoints="${NODE_IPS}:2379"
find $BACKUP_DIR/ -type f -mtime +20 -exec rm -f {} \;