X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpostgres%2Ffiles%2Fbackup_server%2Fpostgres-make-base-backups;h=7bb2e8a86da778ecf6a32c257ef78bbb9614340a;hb=4e813968762b4ac5525ed689919ca8a85ab88f46;hp=d9352bc78855e2e6670ccbf337c52e0e1ad7ab69;hpb=4c79a43803e0f13091ca289ee39ed8c63fee4bb2;p=mirror%2Fdsa-puppet.git diff --git a/modules/postgres/files/backup_server/postgres-make-base-backups b/modules/postgres/files/backup_server/postgres-make-base-backups index d9352bc78..7bb2e8a86 100755 --- a/modules/postgres/files/backup_server/postgres-make-base-backups +++ b/modules/postgres/files/backup_server/postgres-make-base-backups @@ -36,11 +36,29 @@ if [ -z "$ROOTDIR" ]; then fi if [ -t 0 ]; then + verbose=1 +else + verbose=0 +fi + +if [ "$verbose" -gt 0 ]; then console="--progress --verbose" else console="" fi +if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then + echo "Usage: $0 [:]" + 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 @@ -49,20 +67,30 @@ 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" - [ -t 0 ] && echo "Doing $host:$port $version/$cluster: $label" + [ "$verbose" -gt 0 ] && echo "Doing $host:$port $version/$cluster: $label" target="$cluster.BASE.$label.tar.gz" tmp=$(tempfile -d "$ROOTDIR" -p "BASE-$host:$port-" -s ".tar.gz") 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 wannabuild 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 +moszumanska.debian.org 5432 debian-backup main 9.1 EOF