Re: Looking for a script that performs full online backup of postgres in archive mode - Mailing list pgsql-general

From Jukka Inkeri
Subject Re: Looking for a script that performs full online backup of postgres in archive mode
Date
Msg-id ef52c43579e3ce23f58aa579e92bc9fcbc00d2d2@localhost
Whole thread Raw
In response to Looking for a script that performs full online backup of postgres in archive mode  (Chris Barnes <compuguruchrisbarnes@hotmail.com>)
List pgsql-general
 > 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.


pgsql-general by date:

Previous
From: Jan Otto
Date:
Subject: Re: Getting iPhone Simulator App to compile with libpq on Snow Leopard
Next
From: "Albe Laurenz"
Date:
Subject: Re: PostgreSQL 8.3.8 on AIX5.3 : compilation failed