From cb48e84a2a449e37e0d7263cd8c09c91963f1d3f Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Mon, 9 Mar 2020 19:19:34 +0100
Subject: [PATCH] Move postgres rsnapshot conf to /etc/rsnapshot.d

---
 postgres/tasks/main.yml       | 24 +++++++++++-------------
 postgres/templates/crontab.j2 | 10 +++++-----
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/postgres/tasks/main.yml b/postgres/tasks/main.yml
index 652e872..4eb5ce3 100644
--- a/postgres/tasks/main.yml
+++ b/postgres/tasks/main.yml
@@ -8,25 +8,19 @@
       - python3-psycopg2
       - libpq-dev
     state: present
-  tags:
-    - postgres
 
 - name: ensure postgres is started
   service:
     name: postgresql
     state: started
     enabled: true
-  tags:
-    - postgres
 
 - name: ensure we have rsnapshot
   apt:
     name: rsnapshot
     state: present
   tags:
-    - postgres
     - rsnapshot
-    - backup
 
 - name: ensure we have our postgres backup script
   copy:
@@ -36,21 +30,27 @@
     group: root
     mode: '0755'
   tags:
-    - postgres
     - rsnapshot
-    - backup
+
+- name: ensure we have a directory for rsnapshot configuration
+  file:
+    path: /etc/rsnapshot.d
+    state: directory
+    owner: root
+    group: root
+    mode: '0755'
+  tags:
+    - rsnapshot
 
 - name: ensure we have our rsnapshot config
   template:
     src: rsnapshot.conf.j2
-    dest: /etc/rsnapshot.conf
+    dest: /etc/rsnapshot.d/postgres.conf
     owner: root
     group: root
     mode: '0644'
   tags:
-    - postgres
     - rsnapshot
-    - backup
 
 - name: ensure rsnapshot is running regularly
   template:
@@ -60,6 +60,4 @@
     group: root
     mode: '0644'
   tags:
-    - postgres
     - rsnapshot
-    - backup
diff --git a/postgres/templates/crontab.j2 b/postgres/templates/crontab.j2
index 1d0e2f5..ca64c39 100644
--- a/postgres/templates/crontab.j2
+++ b/postgres/templates/crontab.j2
@@ -1,7 +1,7 @@
 {% if postgres_enable_frequently %}
-5,20,35,50 * * * * root /usr/bin/rsnapshot frequently
+5,20,35,50 * * * * root /usr/bin/rsnapshot -c /etc/rsnapshot.d/postgres.conf frequently
 {% endif %}
-3 * * * * root /usr/bin/rsnapshot hourly
-51 23 * * * root /usr/bin/rsnapshot daily
-41 23 * * 6 root /usr/bin/rsnapshot weekly
-31 23 2 * * root /usr/bin/rsnapshot monthly
+3 * * * * root /usr/bin/rsnapshot -c /etc/rsnapshot.d/postgres.conf hourly
+51 23 * * * root /usr/bin/rsnapshot -c /etc/rsnapshot.d/postgres.conf daily
+41 23 * * 6 root /usr/bin/rsnapshot -c /etc/rsnapshot.d/postgres.conf weekly
+31 23 2 * * root /usr/bin/rsnapshot -c /etc/rsnapshot.d/postgres.conf monthly
-- 
GitLab