Temporary test to speed up backup and use correct backup directory for sending emails.

This commit is contained in:
2024-02-24 11:02:05 +01:00
parent 8e76f1ddab
commit 9dc3881659

View File

@@ -23,22 +23,22 @@
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Backup web directories # - name: Backup web directories
shell: tar cvfz {{ backup_dir }}/{{ item.key }}/web-{{ ansible_date_time.iso8601_basic_short }}.tar.gz {{ item.value.storage }} # shell: tar cvfz {{ backup_dir }}/{{ item.key }}/web-{{ ansible_date_time.iso8601_basic_short }}.tar.gz {{ item.value.storage }}
when: item.value.storage is defined # 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: Fetch web backups # - name: Fetch web backups
fetch: # fetch:
src: "{{ backup_dir }}/{{ item.key }}/web-{{ ansible_date_time.iso8601_basic_short }}.tar.gz" # src: "{{ backup_dir }}/{{ item.key }}/web-{{ ansible_date_time.iso8601_basic_short }}.tar.gz"
dest: "{{ local_backup }}/{{ item.key }}/" # dest: "{{ local_backup }}/{{ item.key }}/"
flat: yes # flat: yes
when: item.value.storage is defined # 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: Backup mysql databases - name: Backup mysql databases
shell: docker exec {{ item }}-db mysqldump -u{{ item }} -p{{ lookup('vars', item ~ '-password') }} {{ item }} > {{ backup_dir }}/{{ item }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql shell: docker exec {{ item }}-db mysqldump -u{{ item }} -p{{ lookup('vars', item ~ '-password') }} {{ item }} > {{ backup_dir }}/{{ item }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
@@ -57,7 +57,7 @@
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Sending Email - name: Send Email
community.general.mail: community.general.mail:
host: smtp.vodafonemail.de host: smtp.vodafonemail.de
port: 465 port: 465
@@ -67,7 +67,7 @@
subject: Datenbank Backup subject: Datenbank Backup
body: System {{ ansible_hostname }} has been successfully provisioned. body: System {{ ansible_hostname }} has been successfully provisioned.
attach: attach:
- "{{ backup_dir }}/{{ item }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql.gz" - "{{ backup_dir }}/{{ item.key }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
delegate_to: localhost delegate_to: localhost
when: item.value.email is defined when: item.value.email is defined
loop: "{{ lookup('dict', customers) }}" loop: "{{ lookup('dict', customers) }}"