diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-28 10:32:51 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-28 10:46:41 +0200 |
commit | 33d0c69450127732c7105145b5e587811ffd644b (patch) | |
tree | 2e142305fbbfd7ece51ffb29f6fe2164ee6934e5 /modules/profile/templates | |
parent | 83341b3ca1ef7dbba1afaea41a722b43e50bdb5b (diff) | |
download | Puppet-33d0c69450127732c7105145b5e587811ffd644b.tar.gz Puppet-33d0c69450127732c7105145b5e587811ffd644b.tar.zst Puppet-33d0c69450127732c7105145b5e587811ffd644b.zip |
Pause replication before the postgresql backup
Diffstat (limited to 'modules/profile/templates')
-rw-r--r-- | modules/profile/templates/postgresql/backup_psql.sh.erb | 13 |
1 files changed, 13 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -euo pipefail | ||
4 | |||
5 | resume_replication() { | ||
6 | /usr/bin/psql -h <%= @pg_path %><%= @pg_port_arg %> -c "SELECT pg_wal_replay_resume();" >/dev/null || echo "impossible to resume replication" | ||
7 | } | ||
8 | |||
9 | trap resume_replication EXIT | ||
10 | |||
11 | /usr/bin/psql -h <%= @pg_path %><%= @pg_port_arg %> -c "SELECT pg_wal_replay_pause();" >/dev/null || (echo "impossible to pause replication" && false) | ||
12 | |||
13 | /usr/bin/pg_dumpall -h <%= @pg_path %><%= @pg_port_arg %> -f <%= @pg_backup_path %>/$(date -Iseconds).sql | ||