diff --git a/library/roles/postgresql/tasks/postgresql-backup.yml b/library/roles/postgresql/tasks/postgresql-backup.yml index 690409f..a88e364 100644 --- a/library/roles/postgresql/tasks/postgresql-backup.yml +++ b/library/roles/postgresql/tasks/postgresql-backup.yml @@ -1,11 +1,26 @@ --- - name: Backup script for the postgresql database(s) copy: src=postgresql-backup.sh dest=/usr/local/sbin/postgresql-backup owner=root mode=0744 - tags: [ 'pg_backup', 'postgresql', 'postgres' ] + copy: src=postgresql-backup.cron dest=/usr/local/sbin/postgresql-backup.cron owner=root mode=0744 + tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ] -- name: cron job for the postgresql database(s) backup +- name: daily cron job for the postgresql database(s) backup copy: src=postgresql-backup.cron dest=/etc/cron.daily/postgresql-backup owner=root mode=0744 - tags: [ 'pg_backup', 'postgresql', 'postgres' ] + when: pgbackup_cron_step is undefined or + pgbackup_cron_step < 1 or + pgbackup_cron_step > 12 + tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ] + +- name: hour step cron job for the postgresql database(s) backup + cron: + name: "hourly step postgresql dump" + minute: "10" + hour: "*/{{ pgbackup_cron_step }}" + job: "/usr/local/sbin/postgresql-backup.cron" + when: pgbackup_cron_step is defined and + pgbackup_cron_step >=1 and + pgbackup_cron_step <= 12 + tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ] - name: postgresql backup defaults template: src=pg_backup-default.j2 dest=/etc/default/pg_backup owner=root mode=0744