diff --git a/roles/pgadmin4/tasks/directories.yml b/roles/pgadmin4/tasks/directories.yml index 8c3e037..51033f6 100644 --- a/roles/pgadmin4/tasks/directories.yml +++ b/roles/pgadmin4/tasks/directories.yml @@ -14,4 +14,6 @@ owner: pgadmin4_{{ pga_id }} - path: "{{ pga_root_dir }}/meta" mode: 700 + - path: "{{ pga_root_dir }}/backup" + mode: 700 tags: pgadmin4 diff --git a/roles/pgadmin4/tasks/install.yml b/roles/pgadmin4/tasks/install.yml index 2f75bca..a163150 100644 --- a/roles/pgadmin4/tasks/install.yml +++ b/roles/pgadmin4/tasks/install.yml @@ -75,3 +75,9 @@ when: pga_systemd_unit.changed tags: pgadmin4 +- name: Install backup hooks + template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/pgadmin_{{ pga_id }} mode=755 + loop: + - pre + - post + tags: pgadmin4 diff --git a/roles/pgadmin4/templates/post-backup.j2 b/roles/pgadmin4/templates/post-backup.j2 new file mode 100644 index 0000000..fbc617e --- /dev/null +++ b/roles/pgadmin4/templates/post-backup.j2 @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eo pipefail + +rm -f {{ pga_root_dir }}/backup/* diff --git a/roles/pgadmin4/templates/pre-backup.j2 b/roles/pgadmin4/templates/pre-backup.j2 new file mode 100644 index 0000000..816824b --- /dev/null +++ b/roles/pgadmin4/templates/pre-backup.j2 @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eo pipefail + +sqlite3 {{ pga_root_dir }}/data/pgadmin4.db .dump | zstd -c > {{ pga_root_dir }}/backup/pgadmin4.sql.zst