From 692412c0e9484c7e8d198fbb91585b28eb0282cf Mon Sep 17 00:00:00 2001 From: Christian Steinle Date: Thu, 18 Nov 2021 12:12:24 +0100 Subject: [PATCH] Extend cleanup to weekly and monthly directories. --- odroid.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/odroid.yaml b/odroid.yaml index 7335c81..305e9e0 100644 --- a/odroid.yaml +++ b/odroid.yaml @@ -101,7 +101,7 @@ - name: Find old daily backups find: - paths: "{{ backup_dir }}/{{ item }}/daily/" + paths: "{{ backup_dir }}/{{ item }}/daily" file_type: file age: 1h age_stamp: ctime @@ -125,9 +125,18 @@ age: 1h age_stamp: ctime patterns: '*.sql.gz' + recurse: false register: oldBackups loop: "{{ databases }}" + - name: Delete old weekly backups + file: + path: "{{ item.path }}" + state: absent + with_items: "{{ oldBackups.results | map(attribute='files') | list }}" + loop_control: + label: "{{ item.path }}" + - name: Find old monthly backups find: paths: "{{ backup_dir }}/{{ item }}/monthly" @@ -135,5 +144,14 @@ age: 13m age_stamp: ctime patterns: '*.sql.gz' + recurse: false register: oldBackups loop: "{{ databases }}" + + - name: Delete old monthly backups + file: + path: "{{ item.path }}" + state: absent + with_items: "{{ oldBackups.results | map(attribute='files') | list }}" + loop_control: + label: "{{ item.path }}"