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

View File

@@ -12,6 +12,7 @@ customers:
database: c2_buehler database: c2_buehler
svj: svj:
database: c4_svj database: c4_svj
storage: /var/www/clients/client4/web4/web/media/svjf
maier: maier:
database: c5_maier database: c5_maier
ispconfig: ispconfig: