#!/bin/sh # This script must be run as root (because it su:s to the database # user. Make sure that it can su, ie the data base user has a valid # shell) with the kerberos tickets needed to write the backups into # AFS and must be run locally on the database server. PGUSER=postgres export PGUSER PGSQLDIR=/mpkg/postgresql/7.3/bin export PGSQLDIR PGBACKUPDIR=/usr/local/staff/backup/postgresql export PGBACKUPDIR PGDBHOME=/misc0/postgresql export PGDBHOME PATH=/sbin:/usr/sbin:/usr/bin:$PGSQLDIR export PATH GZIP=/usr/bin/gzip KAUTH=/usr/athena/bin/kauth KSERVICETAB=/etc/athena/srvtab.postgres KSERVICENAME=service.postgres KDESTROY=/usr/athena/bin/kdestroy KSU=/usr/athena/bin/su SHOSTNAME=`/usr/bin/hostname -s` TIMESTAMP=`/sbin/date +"%Y-%m-%d_%H:%M"` DUMPFILE=pgdump.$SHOSTNAME.$TIMESTAMP export DUMPFILE $KSU -K $PGUSER -c $PGSQLDIR/pg_dumpall > /tmp/$DUMPFILE if [ -f /tmp/$DUMPFILE ] ; then # Compress it $GZIP -9 /tmp/$DUMPFILE # Move it into AFS $KAUTH -f $KSERVICETAB -n $KSERVICENAME mv /tmp/$DUMPFILE.gz $PGBACKUPDIR/$DUMPFILE.gz $KDESTROY >/dev/null fi # Do garbage collection $PGSQLDIR/vacuumdb -a > /dev/null