Have postgres-make-base-backups use postgres-make-one-base-backup
[mirror/dsa-puppet.git] / modules / postgres / templates / backup_server / postgres-make-base-backups.erb
1 #!/bin/bash
2
3 # run a bunch of full postgresql backups
4 # vim:syn=sh:
5
6
7 # Copyright 2014 Peter Palfrader
8 #
9 # Permission is hereby granted, free of charge, to any person obtaining
10 # a copy of this software and associated documentation files (the
11 # "Software"), to deal in the Software without restriction, including
12 # without limitation the rights to use, copy, modify, merge, publish,
13 # distribute, sublicense, and/or sell copies of the Software, and to
14 # permit persons to whom the Software is furnished to do so, subject to
15 # the following conditions:
16 #
17 # The above copyright notice and this permission notice shall be
18 # included in all copies or substantial portions of the Software.
19 #
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28
29 set -e
30 set -u
31
32 if [ -t 0 ]; then
33         verbose=1
34 else
35         verbose=0
36 fi
37
38 if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
39         echo "Usage: $0 [<host>:<port>]"
40         exit 0
41 fi
42
43 if [ "$#" -gt 0 ]; then
44         forcehostport="$1"
45         shift
46 else
47         forcehostport=""
48 fi
49
50 while read host port username  cluster version; do
51         [ "${host#\#}" = "$host" ] || continue
52         [ -z "$host" ] && continue
53
54         if [ -n "$forcehostport" ] && [ "$forcehostport" != "$host:$port" ]; then
55                 [ "$verbose" -gt 0 ] && echo "Skipping $host:$port $version/$cluster."
56                 continue
57         fi
58
59         /usr/local/bin/postgres-make-one-base-backup "$host" "$port" "$username" "$cluster" "$version"
60 done << EOF
61 seger.debian.org        5432    debian-backup           dak             9.6
62 bmdb1.debian.org        5435    debian-backup           main            9.6
63 bmdb1.debian.org        5436    debian-backup           wannabuild      9.6
64 bmdb1.debian.org        5440    debian-backup           debsources      9.6
65 fasolo.debian.org       5433    debian-backup           dak             9.6
66 sibelius.debian.org     5433    debian-backup           snapshot        9.4
67 <%- if @hostname != "backuphost" -%>
68 moszumanska.debian.org  5432    debian-backup           main            9.1
69 <%- end -%>
70 #
71 # puppet notice:  this is just a partial file.  The tail EOF comes
72 # from a different concat fragment