Re: Looking for a script that performs full online backup of postgres in archive mode

From: Jukka Inkeri <pg(at)awot(dot)fi>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Looking for a script that performs full online backup of postgres in archive mode
Date: 2009-11-09 14:44:17
Message-ID: ef52c43579e3ce23f58aa579e92bc9fcbc00d2d2@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2009-11-09 15:32:04 Re: PostgreSQL 8.3.8 on AIX5.3 : compilation failed
Previous Message Jan Otto 2009-11-09 14:40:57 Re: Getting iPhone Simulator App to compile with libpq on Snow Leopard