From bf1f483aa2c4b24e08e99b31a0594acfb175cac5 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 24 Feb 2024 09:52:37 +0100 Subject: [PATCH] Extend backup for strato-production. --- strato-production.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/strato-production.yaml b/strato-production.yaml index a6168f9..57c5c2f 100644 --- a/strato-production.yaml +++ b/strato-production.yaml @@ -5,28 +5,23 @@ gather_facts: true tasks: - - name: Backup odroid + - name: Backup strato-production block: - include_vars: vars/mattermost.yaml - include_vars: vars/strato-production.yaml - - name: Check if directories exist - stat: - path: "{{ backup_dir }}/{{ item }}" - register: dirs - loop: "{{ systems }}" - - - name: Create not existing directories + - name: Create backup directory file: - path: "{{ backup_dir }}/{{ item.item }}" + path: "{{ backup_dir }}" state: directory - mode: 0755 - group: chris - owner: chris - when: item.stat.exists == false - with_items: "{{ dirs.results }}" + + - name: Create customer directories + file: + path: "{{ backup_dir }}/{{ item.key }}" + state: directory + loop: "{{ lookup('dict', customers) }}" loop_control: - label: "{{ item.item }}" + label: "{{ item.key }}" - 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 @@ -45,6 +40,11 @@ loop_control: label: "{{ item.key }}" + - name: Clean backup directory + file: + path: "{{ backup_dir }}" + state: absent + - name: Inform Mattermost about success uri: url: "{{ mattermost_url }}"