From 33d0c69450127732c7105145b5e587811ffd644b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 28 May 2019 10:32:51 +0200 Subject: Pause replication before the postgresql backup --- modules/profile/templates/postgresql/backup_psql.sh.erb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 modules/profile/templates/postgresql/backup_psql.sh.erb (limited to 'modules/profile/templates/postgresql') diff --git a/modules/profile/templates/postgresql/backup_psql.sh.erb b/modules/profile/templates/postgresql/backup_psql.sh.erb new file mode 100644 index 0000000..cf353b0 --- /dev/null +++ b/modules/profile/templates/postgresql/backup_psql.sh.erb @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +resume_replication() { + /usr/bin/psql -h <%= @pg_path %><%= @pg_port_arg %> -c "SELECT pg_wal_replay_resume();" >/dev/null || echo "impossible to resume replication" +} + +trap resume_replication EXIT + +/usr/bin/psql -h <%= @pg_path %><%= @pg_port_arg %> -c "SELECT pg_wal_replay_pause();" >/dev/null || (echo "impossible to pause replication" && false) + +/usr/bin/pg_dumpall -h <%= @pg_path %><%= @pg_port_arg %> -f <%= @pg_backup_path %>/$(date -Iseconds).sql -- cgit v1.2.3