一般而言,etcd都是集羣部署,其實並不須要額外備份,但實在是架不住豬隊友誤操做。rest
寫一個簡單的etcd備份腳本以下:code
#!/bin/bash set -e exec >> /var/log/backup_etcd.log Date=`date +%Y-%m-%d-%H-%M` EtcdEndpoints="localhost:2379" EtcdCmd="/usr/bin/etcdctl" BackupDir="/home/www/server/backup/etcd" BackupFile="snapshot.db.$Date" echo "`date` backup etcd..." export ETCDCTL_API=3 $EtcdCmd --endpoints $EtcdEndpoints snapshot save $BackupDir/$BackupFile echo "`date` backup done!"
etcdctl snapshot restore snapshot.db.2019-05-21-10-02 -data-dir /home/www/server/etcd
參數說明:server