From 8def2b06cdc0c5884fbf48d8c719a9c27d6d71c8 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 8 Nov 2021 13:00:08 +0100 Subject: [PATCH] Update to 2021-11-08 13:00 --- roles/pgadmin4/tasks/directories.yml | 2 ++ roles/pgadmin4/tasks/install.yml | 6 ++++++ roles/pgadmin4/templates/post-backup.j2 | 5 +++++ roles/pgadmin4/templates/pre-backup.j2 | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 roles/pgadmin4/templates/post-backup.j2 create mode 100644 roles/pgadmin4/templates/pre-backup.j2 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