aboutsummaryrefslogtreecommitdiff
path: root/modules/profile
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profile')
-rw-r--r--modules/profile/manifests/postgresql/backup_dump.pp9
-rw-r--r--modules/profile/templates/postgresql/backup_psql.sh.erb13
2 files changed, 20 insertions, 2 deletions
diff --git a/modules/profile/manifests/postgresql/backup_dump.pp b/modules/profile/manifests/postgresql/backup_dump.pp
index 7578027..cae20f7 100644
--- a/modules/profile/manifests/postgresql/backup_dump.pp
+++ b/modules/profile/manifests/postgresql/backup_dump.pp
@@ -30,13 +30,18 @@ define profile::postgresql::backup_dump (
30 $pg_port_arg = "" 30 $pg_port_arg = ""
31 } 31 }
32 32
33 file { "/usr/local/sbin/backup_psql_$pg_host.sh":
34 mode => "0755",
35 content => template("profile/postgresql/backup_psql.sh.erb"),
36 }
37
33 if ($pg_host == "eldiron.immae.eu") { 38 if ($pg_host == "eldiron.immae.eu") {
34 cron::job::multiple { "backup_psql_$pg_host": 39 cron::job::multiple { "backup_psql_$pg_host":
35 ensure => "present", 40 ensure => "present",
36 require => [File[$pg_backup_path], File[$pg_path]], 41 require => [File[$pg_backup_path], File[$pg_path]],
37 jobs => [ 42 jobs => [
38 { 43 {
39 command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", 44 command => "/usr/local/sbin/backup_psql_$pg_host.sh",
40 user => $pg_user, 45 user => $pg_user,
41 hour => "22,4,10,16", 46 hour => "22,4,10,16",
42 minute => 0, 47 minute => 0,
@@ -57,7 +62,7 @@ define profile::postgresql::backup_dump (
57 require => [File[$pg_backup_path], File[$pg_path]], 62 require => [File[$pg_backup_path], File[$pg_path]],
58 jobs => [ 63 jobs => [
59 { 64 {
60 command => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql", 65 command => "/usr/local/sbin/backup_psql_$pg_host.sh",
61 user => $pg_user, 66 user => $pg_user,
62 hour => "22,4,10,16", 67 hour => "22,4,10,16",
63 minute => 0, 68 minute => 0,
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
3set -euo pipefail
4
5resume_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
9trap 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