1. Backup etcd1.1 manually back up data
etcdctl backup --data-dir /var/lib/etcd/default.etcd --backup-dir 备份目录
1.2 Script backup Data
Use the ETCD command etcdctl for etc Backup, the script is as follows:
#!/bin/bashdate_time=`date +%Y%m%d`etcdctl backup --data-dir /var/lib/etcd/default.etcd --backup-dir /root/etcd71-${date_time}.etcdtar cvzf etcd71-${date_time}.tar.gz etcd71-${date_time}.etcd
1.3 Delete 7 days ago Historical backup
find /root/*.etcd -ctime +7 -exec rm -r {} \;find /root/*.gz -ctime +7 -exec rm -r {} \;
2. Restore etcd2.1 stand-alone operation
etcd --data-dir=/var/lib/etcd/default.etcd --force-new-cluster &
2.2 View ID
etcdctl member list1c4358be138c6d94: name=default peerURLs=https://192.168.61.71:2380 clientURLs=http://localhost:2379 isLeader=true
2.3 Data Synchronization
curl http://127.0.0.1:2379/v2/members/1c4358be138c6d94 -XPUT -H "Content-Type:application/json" -d ‘{"peerURLs":["http://127.0.0.1:2379"]}‘
2.4 End stand-alone operation
pkill -9 etcd
2.5 Restarting the service
systemctl restart etcdsystemctl status etcd
ETCD database backup and restore