$pg_port_arg = ""
}
+ file { "/usr/local/sbin/backup_psql_$pg_host.sh":
+ mode => "0755",
+ content => template("profile/postgresql/backup_psql.sh.erb"),
+ }
+
if ($pg_host == "eldiron.immae.eu") {
cron::job::multiple { "backup_psql_$pg_host":
ensure => "present",
require => [File[$pg_backup_path], File[$pg_path]],
jobs => [
{
- command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql",
+ command => "/usr/local/sbin/backup_psql_$pg_host.sh",
user => $pg_user,
hour => "22,4,10,16",
minute => 0,
require => [File[$pg_backup_path], File[$pg_path]],
jobs => [
{
- command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql",
+ command => "/usr/local/sbin/backup_psql_$pg_host.sh",
user => $pg_user,
hour => "22,4,10,16",
minute => 0,
--- /dev/null
+#!/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