/ Published in: Bash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/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 correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null sleep 10 nail -s "PostgreSql Backup ("$time") [base2]" -a $BACKUP_DIR/base2-$time.gz -c correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null sleep 10 nail -s "PostgreSql Backup ("$time") [roles]" -a $BACKUP_DIR/roles-$time.gz -c correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null sleep 10 #echo "-- Envio de e-mail finalizado" exit 0