Skip to content

Commit

Permalink
修改ectd 备份命令和备份路径均在 ansible 节点
Browse files Browse the repository at this point in the history
  • Loading branch information
itswl authored and gjmzj committed Nov 16, 2022
1 parent 1f29e94 commit 90a5755
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions playbooks/94.backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@
shell: "date +'%Y%m%d%H%M'"
register: timestamp

# step2: backup data on the healthy member
# step2: backup data to the ansible node
- name: make a backup on the etcd node
shell: "mkdir -p /etcd_backup && cd /etcd_backup && \
ETCDCTL_API=3 {{ bin_dir }}/etcdctl snapshot save snapshot_{{ timestamp.stdout }}.db"
shell: "mkdir -p {{ cluster_dir }}/backup && cd {{ cluster_dir }}/backup && \
ETCDCTL_API=3 {{ base_dir }}/bin/etcdctl \
--endpoints=https://{{ RUNNING_NODE.stdout }}:2379 \
--cacert={{ cluster_dir }}/ssl/ca.pem \
--cert={{ cluster_dir }}/ssl/etcd.pem \
--key={{ cluster_dir }}/ssl/etcd-key.pem \
snapshot save snapshot_{{ timestamp.stdout }}.db"
args:
warn: false
delegate_to: "{{ RUNNING_NODE.stdout }}"

- name: fetch the backup data
fetch:
src: /etcd_backup/snapshot_{{ timestamp.stdout }}.db
dest: "{{ cluster_dir }}/backup/"
flat: yes
delegate_to: "{{ RUNNING_NODE.stdout }}"

- name: update the latest backup
shell: 'cd {{ cluster_dir }}/backup/ && /bin/cp -f snapshot_{{ timestamp.stdout }}.db snapshot.db'

0 comments on commit 90a5755

Please sign in to comment.