> have a shell script that
performs a full online backup of postgres?

Full backup ex. pg_dumpall

Daily backup (dump) / database:
- - - - - - - - - - - - - - -
#!/someshellpath like /bin/sh or /bin/bash or /bin/ksh ...
#daily.sh
#default plaintext
#usage: daily.sh [c|t|p]
#
PORT=5432
HOST="localhost"
DB="mysomedb"
DB_USER="myusername"
FORMAT="p"  # c t p=plaintext
TYPE="txt"
COMPRESS=1
case "$1" in
        c) FORMAT="c"; COMPRESS=0;;
        t) FORMAT="t";;
        p) FORMAT="p";;
esac
case "$FORMAT" in
        c) TYPE=comp ;;
        t) TYPE=tar ;;
        p) TYPE="txt" ;;
esac
day=$(date '+%d');

pg_dump -F "$FORMAT" -p "$PORT" -h "$HOST" -U "$DB_USER" "$DB" > daily.$day.backup.$TYPE
[ "$COMPRESS" = 0 ] && exit 0

# compress daily.$day.backup.$TYPE
gzip daily.$day.backup.$TYPE

- - - - - - - - - - - - - - -
Remember - test also your restore procedure.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to