FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 67d141b5 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Ensure pg-dump-script includes a dump of roles

We don't always need the role data, if the presumption is that we'll
be doing a pg_restore in conjunction with an ansible role which creates
all required roles. But, having a copy of the role data will never hurt!
It also gives us a straightforward way of restoring a database to a
standalone postgres instance without having to have provisioned a
dedicated VM with the relevant ansible roles.
parent 5b4a8757
No related branches found
Tags 0.9-ch84
No related merge requests found
......@@ -3,6 +3,6 @@ Priority: optional
Section: otherosfs
Maintainer: Chemistry COs <support@ch.cam.ac.uk>
Architecture: all
Version: 0.9-ch83
Version: 0.9-ch84
Depends: zfs-dkms, postgresql-13 | postgresql-9.5 | postgresql-9.4 , liblockfile-simple-perl, libdbi-perl, libjson-perl, libzfs-perl-chem, libnet-openssh-perl, libdbd-pg-perl, mbuffer, rsync, nfs-kernel-server, pv, libwww-curl-perl
Description: a backup system using ZFS (repository 'backup-scheduler')
......@@ -36,9 +36,11 @@ unset PGPASSFILE
TEMPDIR=$(ssh ${SSHUSER}@${HOSTNAME} mktemp -d /tmp/pgXXXXX)
MOUNT=$(zfs get -H -ovalue mountpoint $ZFSTARGET)
BACKUP_DEST=$MOUNT/pgdumps/pgdumps-master/
BACKUP_ROOT=$MOUNT/pgdumps
PGDUMP_DEST=$BACKUP_ROOT/pgdumps-master/
PGROLE_DEST=$BACKUP_ROOT/pg_roles
mkdir -p $BACKUP_DEST
mkdir -p $PGDUMP_DEST
# we need this to exist for the rsync part of the backup, so the rsync returns successfully
ssh ${SSHUSER}@${HOSTNAME} mkdir -p /var/empty
......@@ -48,6 +50,11 @@ ssh ${SSHUSER}@${HOSTNAME} mkdir -p /var/empty
# script which called us.
ssh ${SSHUSER}@${HOSTNAME} pg_dump $PGDUMP_EXTRA_OPTIONS --host localhost --blobs --clean --user _pgbackup $PGDUMP_DATABASE -Fd -f $TEMPDIR/pgdump || exit 1
# Dump role info
ssh ${SSHUSER}@${HOSTNAME} "sudo -u postgres pg_dumpall -r > $TEMPDIR/pg_roles" || exit 1
# Rsync to backup destination
rsync -av --checksum --delete --no-times ${SSHUSER}@${HOSTNAME}:$TEMPDIR/pgdump/ $BACKUP_DEST
rsync -av --checksum --delete --no-times ${SSHUSER}@${HOSTNAME}:$TEMPDIR/pgdump/ $PGDUMP_DEST
scp ${SSHUSER}@${HOSTNAME}:$TEMPDIR/pg_roles $PGROLE_DEST
# TEMPDIR will be removed on exit by tidytmp()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment