Check if storage must be backed up.

This commit is contained in:
2021-11-22 07:28:21 +01:00
parent 42b117fb9a
commit e37699d9e0
2 changed files with 24 additions and 17 deletions

View File

@@ -21,27 +21,33 @@
loop_control:
label: "{{ item.key }}"
- name: Backup databases
shell: mysqldump -u{{ mysql_user }} -p{{ mysql_password }} {{ item.value.database }} > {{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
- name: Create storage backups
debug: var=item.key
when: item.value.storage is defined
loop: "{{ lookup('dict', customers) }}"
loop_control:
label: "{{ item.key }}"
- name: Compress database backups
shell: gzip {{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
loop: "{{ lookup('dict', customers) }}"
loop_control:
label: "{{ item.key }}"
- name: Fetch backups
fetch:
src: "{{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
dest: "{{ local_backup }}/{{ item.key }}/"
flat: yes
loop: "{{ lookup('dict', customers) }}"
loop_control:
label: "{{ item.key }}"
# - name: Backup databases
# shell: mysqldump -u{{ mysql_user }} -p{{ mysql_password }} {{ item.value.database }} > {{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
# loop: "{{ lookup('dict', customers) }}"
# loop_control:
# label: "{{ item.key }}"
#
# - name: Compress database backups
# shell: gzip {{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
# loop: "{{ lookup('dict', customers) }}"
# loop_control:
# label: "{{ item.key }}"
#
# - name: Fetch database backups
# fetch:
# src: "{{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
# dest: "{{ local_backup }}/{{ item.key }}/"
# flat: yes
# loop: "{{ lookup('dict', customers) }}"
# loop_control:
# label: "{{ item.key }}"
- name: Clean backup directory
file: