]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/postgres/files/backup_server/postgres-make-base-backups
postgres: add wanna-build-ports in the base backups
[dsa-puppet.git] / modules / postgres / files / backup_server / postgres-make-base-backups
index ee9213fff4752aa028c93d9325d6c69580d8f317..e3e6d7f769c19b6e1ea9b52ea08b43e72b03a4e4 100755 (executable)
@@ -39,6 +39,7 @@ if [ -t 0 ]; then
        verbose=1
 else
        verbose=0
+fi
 
 if [ "$verbose" -gt 0 ]; then
        console="--progress --verbose"
@@ -46,6 +47,18 @@ else
        console=""
 fi
 
+if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
+       echo "Usage: $0 [<host>:<port>]"
+       exit 0
+fi
+
+if [ "$#" -gt 0 ]; then
+       forcehostport="$1"
+       shift
+else
+       forcehostport=""
+fi
+
 export PGSSLMODE=verify-full
 export PGSSLROOTCERT=/etc/ssl/debian/certs/ca.crt
 
@@ -54,6 +67,11 @@ date=$(date "+%Y%m%d-%H%M%S")
 while read host port username  cluster version; do
        [ "${host#\#}" = "$host" ] || continue
 
+       if [ -n "$forcehostport" ] && [ "$forcehostport" != "$host:$port" ]; then
+               [ "$verbose" -gt 0 ] && echo "Skipping $host:$port $version/$cluster."
+               continue
+       fi
+
        label="$date-$host-$cluster-$version-backup"
        [ "$verbose" -gt 0 ] && echo "Doing $host:$port $version/$cluster: $label"
 
@@ -62,11 +80,16 @@ while read host port username  cluster version; do
        trap "rm -f '$tmp'" EXIT
 
        /usr/lib/postgresql/"$version"/bin/pg_basebackup --format=tar --pgdata=- --label="$label" --host="$host" --port="$port" --username="$username" --no-password $console | pigz > "$tmp"
+       if ! [ "${PIPESTATUS[0]}" -eq 0 ]; then
+               echo >&2 "pg_basebackup failed with exit code ${PIPESTATUS[0]}"
+               exit 1
+       fi
        mv "$tmp" "$ROOTDIR/${host%%.*}/$target"
 done << EOF
 chopin.debian.org      5432    debian-backup           dak             9.1
 bmdb1.debian.org       5435    debian-backup           main            9.1
 bmdb1.debian.org       5436    debian-backup           wanna-build     9.1
+bmdb1.debian.org       5436    debian-backup           wanna-build-ports       9.1
 danzi.debian.org       5433    debian-backup           main            9.1
 franck.debian.org      5433    debian-backup           dak             9.1
 sibelius.debian.org    5433    debian-backup           snapshot        9.1