点击查看代码
[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 {} \;