mirror of https://github.com/easzlab/kubeasz.git
parent
492c93a03d
commit
13439cba05
|
@ -4,27 +4,20 @@
|
||||||
- name: 清除etcd 数据目录
|
- name: 清除etcd 数据目录
|
||||||
file: name={{ ETCD_DATA_DIR }}/member state=absent
|
file: name={{ ETCD_DATA_DIR }}/member state=absent
|
||||||
|
|
||||||
- name: 生成备份目录
|
- name: 清除 etcd 备份目录
|
||||||
file: name=/etcd_backup state=directory
|
file: name={{ cluster_dir }}/backup/etcd-restore state=absent
|
||||||
|
delegate_to: 127.0.0.1
|
||||||
- name: 准备指定的备份etcd 数据
|
run_once: true
|
||||||
copy:
|
|
||||||
src: "{{ cluster_dir }}/backup/{{ db_to_restore }}"
|
|
||||||
dest: "/etcd_backup/snapshot.db"
|
|
||||||
|
|
||||||
- name: 清理上次备份恢复数据
|
|
||||||
file: name=/etcd_backup/etcd-{{ inventory_hostname }}.etcd state=absent
|
|
||||||
|
|
||||||
- name: etcd 数据恢复
|
- name: etcd 数据恢复
|
||||||
shell: "cd /etcd_backup && \
|
shell: "cd {{ cluster_dir }}/backup && \
|
||||||
ETCDCTL_API=3 {{ bin_dir }}/etcdctl snapshot restore snapshot.db \
|
ETCDCTL_API=3 {{ base_dir }}/bin/etcdctl snapshot restore snapshot.db \
|
||||||
--name etcd-{{ inventory_hostname }} \
|
--data-dir={{ cluster_dir }}/backup/etcd-restore"
|
||||||
--initial-cluster {{ ETCD_NODES }} \
|
delegate_to: 127.0.0.1
|
||||||
--initial-cluster-token etcd-cluster-0 \
|
run_once: true
|
||||||
--initial-advertise-peer-urls https://{{ inventory_hostname }}:2380"
|
|
||||||
|
|
||||||
- name: 恢复数据至etcd 数据目录
|
- name: 分发恢复文件到 etcd 各个节点
|
||||||
shell: "cp -rf /etcd_backup/etcd-{{ inventory_hostname }}.etcd/member {{ ETCD_DATA_DIR }}/"
|
copy: src={{ cluster_dir }}/backup/etcd-restore/member dest={{ ETCD_DATA_DIR }}
|
||||||
|
|
||||||
- name: 重启etcd 服务
|
- name: 重启etcd 服务
|
||||||
service: name=etcd state=restarted
|
service: name=etcd state=restarted
|
||||||
|
|
Loading…
Reference in New Issue