Posted By


Jurasec on 04/06/10

Tagged


Statistics


Viewed 159 times
Favorited by 0 user(s)

backup.postgresql


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/bash
  2.  
  3. BACKUP_DIR=/home/pg-bkp
  4. export PGHOST=localhost
  5. export PGUSER=postgres
  6. export PGPASSWORD=secreta
  7. export PGPORT=5334
  8. time=`date '+%d'-'%B'-'%Y'`
  9. /usr/lib/postgresql/8.4/bin/pg_dump -p $PGPORT -h $PGHOST -U $PGUSER base1 | gzip > $BACKUP_DIR/base1-$time.gz
  10. #echo "-- Respaldo de Base 1 terminada..."
  11. sleep 10
  12. /usr/lib/postgresql/8.4/bin/pg_dump -p $PGPORT -h $PGHOST -U $PGUSER base2 | gzip > $BACKUP_DIR/base2-$time.gz
  13. #echo "-- Respaldo de Base 2 terminada..."
  14. /usr/lib/postgresql/8.4/bin/pg_dumpall -p $PGPORT -h $PGHOST -U $PGUSER -l postgres -r | gzip > $BACKUP_DIR/roles-$time.gz
  15. #echo "-- Respaldo de roles terminado... iniciando el envio de los e-mail"
  16. unset PGPASSWORD
  17. nail -s "PostgreSql Backup ("$time") [base1]" -a $BACKUP_DIR/base1-$time.gz -c correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null
  18. sleep 10
  19. nail -s "PostgreSql Backup ("$time") [base2]" -a $BACKUP_DIR/base2-$time.gz -c correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null
  20. sleep 10
  21. nail -s "PostgreSql Backup ("$time") [roles]" -a $BACKUP_DIR/roles-$time.gz -c correo_copia@yahoo.com.mx correo_respaldo@gmail.com < /dev/null
  22. sleep 10
  23. #echo "-- Envio de e-mail finalizado"
  24. exit 0

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.