X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPuppet.git;a=blobdiff_plain;f=modules%2Fprofile%2Ftemplates%2Fpostgresql%2Fbackup_psql.sh.erb;fp=modules%2Fprofile%2Ftemplates%2Fpostgresql%2Fbackup_psql.sh.erb;h=cf353b04a98bc453d888ef82584cb850b4f80646;hp=0000000000000000000000000000000000000000;hb=33d0c69450127732c7105145b5e587811ffd644b;hpb=83341b3ca1ef7dbba1afaea41a722b43e50bdb5b 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