From d1ec1bc57be7844b10d6b6c10a70d075c1c621a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavi=20Lle=C3=B3=20Tom=C3=A1s?= Date: Wed, 29 Jan 2025 09:51:30 +0100 Subject: [PATCH] =?UTF-8?q?refs=20#8414=20-=20Rsync=20to=20dont=C2=B4t=20f?= =?UTF-8?q?ail=20at=20the=20end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/services/tasks/mariadb.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/roles/services/tasks/mariadb.yml b/roles/services/tasks/mariadb.yml index b831a5c..a10f5ea 100644 --- a/roles/services/tasks/mariadb.yml +++ b/roles/services/tasks/mariadb.yml @@ -71,7 +71,7 @@ # mode: u=rw,g=r,o=r - name: Insert MySQL certificates - #no_log: true + no_log: true copy: content: "{{ item.content }}" dest: "{{ item.dest }}" @@ -104,7 +104,7 @@ - /mnt/local-backup Make sure they are correctly configured and accessible. -- when: production is false +- when: production is false or production is not defined block: - name: Set MariaDB custom configuration Test-DB-DEV @@ -157,3 +157,26 @@ owner: root group: root mode: u=rw,g=,o= + +- name: Check if /var/lib/mysql/ exists + stat: + path: /var/lib/mysql/ + register: mysql_dir + + +- when: mysql_dir.stat.exists + block: + + - name: Sync MySQL data directory + synchronize: + src: /var/lib/mysql/ + dest: /mnt/mysqldata/mysql/ + archive: true + compress: true + recursive: true + delegate_to: "{{ inventory_hostname }}" + + - name: Remove old MySQL data after sync + file: + path: /var/lib/mysql/ + state: absent