diff --git a/files/pg_cleanup b/files/pg_cleanup new file mode 100644 index 0000000..b1002e6 --- /dev/null +++ b/files/pg_cleanup @@ -0,0 +1,3 @@ +#!/bin/sh -e + +sudo -u postgres sh -e -c "test -d /var/lib/postgresql/backups/12/main && find /var/lib/postgresql/backups/12/main -type f -mtime +35 -exec rm {} \;" diff --git a/playbooks/deploy/postgres.yml b/playbooks/deploy/postgres.yml index ad025e4..e2e3bbe 100644 --- a/playbooks/deploy/postgres.yml +++ b/playbooks/deploy/postgres.yml @@ -16,3 +16,11 @@ mode: 'u=rwx,g=rx,o=rx' owner: root group: root + + - name: Create daily Cron job for PostgreSQL cleanup + copy: + src: ../../files/pg_cleanup + dest: /etc/cron.daily/pg_cleanup + mode: 'u=rwx,g=rx,o=rx' + owner: root + group: root