mirror of https://github.com/easzlab/kubeasz.git
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
# cluster-backup playbook
|
|
# read the guide: 'op/cluster_restore.md'
|
|
|
|
- hosts:
|
|
- etcd
|
|
roles:
|
|
- cluster-backup
|
|
|
|
- hosts:
|
|
- deploy
|
|
tasks:
|
|
- name: Creating backup dirs
|
|
file: name={{ item }} state=directory
|
|
with_items:
|
|
- "{{ base_dir }}/roles/cluster-backup/files/ca"
|
|
- "{{ base_dir }}/roles/cluster-backup/files/hosts"
|
|
- "{{ base_dir }}/roles/cluster-backup/files/snapshot"
|
|
|
|
- name: Backing up CA sth
|
|
copy:
|
|
src: "{{ ca_dir }}/{{ item }}"
|
|
dest: "{{ base_dir }}/roles/cluster-backup/files/ca/{{ item }}"
|
|
with_items:
|
|
- ca.pem
|
|
- ca-key.pem
|
|
- ca.csr
|
|
- ca-csr.json
|
|
- ca-config.json
|
|
|
|
- name: Backing up ansible hosts-1
|
|
copy:
|
|
src: "{{ base_dir }}/hosts"
|
|
dest: "{{ base_dir }}/roles/cluster-backup/files/hosts/hosts"
|
|
register: p
|
|
|
|
- name: Backing up ansible hosts-2
|
|
shell: "cd {{ base_dir }}/roles/cluster-backup/files/hosts && \
|
|
cp -fp hosts hosts-$(date +'%Y%m%d%H%M')"
|
|
when: 'p is changed'
|
|
|
|
- name: Backing up etcd snapshot-1
|
|
copy:
|
|
src: "{{ base_dir }}/roles/cluster-backup/files/snapshot.db"
|
|
dest: "{{ base_dir }}/roles/cluster-backup/files/snapshot/snapshot.db"
|
|
register: q
|
|
|
|
- name: Backing up etcd snapshot-2
|
|
shell: "cd {{ base_dir }}/roles/cluster-backup/files/ && \
|
|
mv -f snapshot.db snapshot/snapshot-$(date +'%Y%m%d%H%M').db"
|
|
when: 'q is changed'
|
|
|