Return to Snippet

Revision: 25714
at April 6, 2010 23:26 by Jurasec


Initial Code
#!/bin/bash

BACKUP_DIR=/home/pg-bkp
export PGHOST=localhost
export PGUSER=postgres
export PGPASSWORD=secreta
export PGPORT=5334
time=`date '+%d'-'%B'-'%Y'`
/usr/lib/postgresql/8.4/bin/pg_dump -p $PGPORT -h $PGHOST -U $PGUSER base1 | gzip > $BACKUP_DIR/base1-$time.gz
#echo "-- Respaldo de Base 1 terminada..."
sleep 10
/usr/lib/postgresql/8.4/bin/pg_dump -p $PGPORT -h $PGHOST -U $PGUSER base2 | gzip > $BACKUP_DIR/base2-$time.gz
#echo "-- Respaldo de Base 2 terminada..."
/usr/lib/postgresql/8.4/bin/pg_dumpall -p $PGPORT -h $PGHOST -U $PGUSER -l postgres -r | gzip > $BACKUP_DIR/roles-$time.gz
#echo "-- Respaldo de roles terminado... iniciando el envio de los e-mail"
unset PGPASSWORD
nail -s "PostgreSql Backup ("$time") [base1]" -a $BACKUP_DIR/base1-$time.gz -c [email protected] [email protected] < /dev/null
sleep 10
nail -s "PostgreSql Backup ("$time") [base2]" -a $BACKUP_DIR/base2-$time.gz -c [email protected] [email protected] < /dev/null
sleep 10
nail -s "PostgreSql Backup ("$time") [roles]" -a $BACKUP_DIR/roles-$time.gz -c [email protected] [email protected] < /dev/null
sleep 10
#echo "-- Envio de e-mail finalizado"
exit 0

Initial URL


Initial Description


Initial Title
backup.postgresql

Initial Tags


Initial Language
Bash