# 备份etcd数据
etcdctl backup --data-dir /var/lib/etcd/default.etcd --backup-dir /root/etcd71
 
etcd备份
使用etcd自带命令etcdctl进行etc备份,脚本如下:
#!/bin/bash
date_time=`date +%Y%m%d`
etcdctl backup --data-dir /var/lib/etcd/default.etcd --backup-dir /root/etcd71-${date_time}.etcd
tar cvzf etcd71-${date_time}.tar.gz etcd71-${date_time}.etcd
 
find /root/*.etcd -ctime +7 -exec rm -r {} \;
find /root/*.gz -ctime +7 -exec rm -r {} \;
 
# 打包备份数据
tar cvzf etcdback-
 
恢复etcd数据
 
# 单机运行
etcd --data-dir=/var/lib/etcd/default.etcd --force-new-cluster &
 
# 查看id
etcdctl member list
1c4358be138c6d94: name=default peerURLs=https://192.168.61.71:2380 clientURLs=http://localhost:2379 isLeader=true
 
# 数据同步
curl http://127.0.0.1:2379/v2/members/1c4358be138c6d94 -XPUT \
-H "Content-Type:application/json" -d '{"peerURLs":["http://127.0.0.1:2379"]}'
 
# 结束单机运行
pkill -9 etcd
 
# 重新启动服务
systemctl restart etcd
systemctl status etcd

相关文章:

  • 2021-04-04
  • 2021-05-31
  • 2021-12-19
  • 2021-12-24
  • 2021-07-31
猜你喜欢
  • 2021-12-20
  • 2021-11-30
  • 2021-11-28
  • 2021-12-06
相关资源
相似解决方案