Move files for pg-backup-file from roles to postgres module
authorPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 18:25:07 +0000 (20:25 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 18:25:07 +0000 (20:25 +0200)
modules/postgres/files/backup_source/pg-backup-file [new file with mode: 0755]
modules/postgres/manifests/backup_source.pp
modules/postgres/templates/backup_source/pg-backup-file.conf.erb [new file with mode: 0644]
modules/roles/files/postgresql_server/pg-backup-file [deleted file]
modules/roles/templates/postgresql_server/pg-backup-file.conf.erb [deleted file]

diff --git a/modules/postgres/files/backup_source/pg-backup-file b/modules/postgres/files/backup_source/pg-backup-file
new file mode 100755 (executable)
index 0000000..9a432e5
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+# Copyright (c) 2010, 2011, 2013, 2014 Peter Palfrader
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# Archive a postgresql file (WAL or BASE) to the archive server $backuphost
+# can be set in /etc/dsa/pg-backup-file.conf
+
+set -u
+
+backuphost=debbackup@storace
+myhost="`hostname`"
+self="`basename "$0"`[$$]"
+
+if [ "$#" != 3 ] ; then
+       echo >&2 "Usage: $self <cluster> <WAL|BASE> <file>"
+       exit 1
+fi
+
+ssh_options=""
+! [ -e /etc/dsa/pg-backup-file.conf ] || . /etc/dsa/pg-backup-file.conf
+
+cluster="$1"
+what="$2"
+file="$3"
+
+info() {
+       logger -p daemon.info -t "$self" "$1"
+}
+
+croak() {
+       logger -s -p daemon.warn -t "$self" "$1"
+       exit 1
+}
+
+if ! [ -e "$file" ] ; then
+       croak "file $file does not exist"
+fi
+
+size="`stat -c '%s' "$file"`"
+checksum=""
+bn="`basename "$file"`"
+targetname="$cluster.$what.$bn"
+logtuple_start="($myhost,$targetname,$size"
+failures=""
+
+for target in $backuphost; do
+       if [ "${target#/}" != "$target" ]; then
+               info "Archiving to $target: ($targetname,$size)"
+               cp "$file" "$target/$myhost-$targetname"
+       else
+               [ -n "$checksum" ] || checksum="`sha512sum "$file" | awk '{print $1}'`"
+               info "Archiving to $target: ($myhost,$targetname,$size,$checksum)"
+
+               ssh -C "$target" $ssh_options -o BatchMode=yes -o ServerAliveInterval=90 $myhost store-file pg "$targetname" "$size" "$checksum" < "$file"
+               if [ "$?" != 0 ]; then
+                       failures="$failures $logtuple_start,$checksum,$target)"
+               fi
+       fi
+done
+if [ "$failures" != "" ]; then
+       croak "remote store for$failures failed."
+fi
index b406d0d..e642ca7 100644 (file)
@@ -4,15 +4,16 @@
 class postgres::backup_source {
   file { '/usr/local/bin/pg-backup-file':
     mode   => '0555',
-    source => 'puppet:///modules/roles/postgresql_server/pg-backup-file',
+    source => 'puppet:///modules/postgres/backup_sources/pg-backup-file',
   }
+  file { '/etc/dsa/pg-backup-file.conf':
+    content => template('postgres/backup_sources/pg-backup-file.conf.erb'),
+  }
+
   file { '/usr/local/bin/pg-receive-file-from-backup':
     mode   => '0555',
     source => 'puppet:///modules/roles/postgresql_server/pg-receive-file-from-backup',
   }
-  file { '/etc/dsa/pg-backup-file.conf':
-    content => template('roles/postgresql_server/pg-backup-file.conf.erb'),
-  }
 
   ssh::keygen {'postgres': }
 }
diff --git a/modules/postgres/templates/backup_source/pg-backup-file.conf.erb b/modules/postgres/templates/backup_source/pg-backup-file.conf.erb
new file mode 100644 (file)
index 0000000..ff67004
--- /dev/null
@@ -0,0 +1,5 @@
+<%- if @hostname == "sibelius" then -%>
+# use ipv4
+ssh_options="-oAddressFamily=inet"
+<%- end %>
+backuphost="debbackup@backuphost debbackup@storace"
diff --git a/modules/roles/files/postgresql_server/pg-backup-file b/modules/roles/files/postgresql_server/pg-backup-file
deleted file mode 100755 (executable)
index 9a432e5..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/bin/bash
-
-# Copyright (c) 2010, 2011, 2013, 2014 Peter Palfrader
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-# Archive a postgresql file (WAL or BASE) to the archive server $backuphost
-# can be set in /etc/dsa/pg-backup-file.conf
-
-set -u
-
-backuphost=debbackup@storace
-myhost="`hostname`"
-self="`basename "$0"`[$$]"
-
-if [ "$#" != 3 ] ; then
-       echo >&2 "Usage: $self <cluster> <WAL|BASE> <file>"
-       exit 1
-fi
-
-ssh_options=""
-! [ -e /etc/dsa/pg-backup-file.conf ] || . /etc/dsa/pg-backup-file.conf
-
-cluster="$1"
-what="$2"
-file="$3"
-
-info() {
-       logger -p daemon.info -t "$self" "$1"
-}
-
-croak() {
-       logger -s -p daemon.warn -t "$self" "$1"
-       exit 1
-}
-
-if ! [ -e "$file" ] ; then
-       croak "file $file does not exist"
-fi
-
-size="`stat -c '%s' "$file"`"
-checksum=""
-bn="`basename "$file"`"
-targetname="$cluster.$what.$bn"
-logtuple_start="($myhost,$targetname,$size"
-failures=""
-
-for target in $backuphost; do
-       if [ "${target#/}" != "$target" ]; then
-               info "Archiving to $target: ($targetname,$size)"
-               cp "$file" "$target/$myhost-$targetname"
-       else
-               [ -n "$checksum" ] || checksum="`sha512sum "$file" | awk '{print $1}'`"
-               info "Archiving to $target: ($myhost,$targetname,$size,$checksum)"
-
-               ssh -C "$target" $ssh_options -o BatchMode=yes -o ServerAliveInterval=90 $myhost store-file pg "$targetname" "$size" "$checksum" < "$file"
-               if [ "$?" != 0 ]; then
-                       failures="$failures $logtuple_start,$checksum,$target)"
-               fi
-       fi
-done
-if [ "$failures" != "" ]; then
-       croak "remote store for$failures failed."
-fi
diff --git a/modules/roles/templates/postgresql_server/pg-backup-file.conf.erb b/modules/roles/templates/postgresql_server/pg-backup-file.conf.erb
deleted file mode 100644 (file)
index ff67004..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<%- if @hostname == "sibelius" then -%>
-# use ipv4
-ssh_options="-oAddressFamily=inet"
-<%- end %>
-backuphost="debbackup@backuphost debbackup@storace"