From: | "Milen A(dot) Radev" <milen(at)radev(dot)net> |
---|---|
To: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Encoding problem using pg_dumpall |
Date: | 2009-02-01 00:59:35 |
Message-ID: | gm2s5m$9g5$1@ger.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-general |
Cliff Pratt написа:
[...]
> You should be able to knock up a simple script in bash, perl or python
> to do what you want.
>
> Sort of like:
>
> Use 'psql' to get a list of the databases
> Sanitize the list.
> Loop through the list doing backup.
> At the end zip them all.
>
> With a little bit of trickery you should be able to zip them as you go.
[...]
#!/bin/bash
PSQL=/usr/bin/psql
PG_DUMP=/usr/bin/pg_dump
PG_DUMPALL=/usr/bin/pg_dumpall
if [ $# -eq 0 ] ; then
BACKUPDIR=/home/db_backup/dumps
elif [ $# -ne 1 ] ; then
echo -e "Usage: $0 [directory]\n"
exit 1
else
BACKUPDIR=$1
fi
if [ ! -d $BACKUPDIR ] ; then
if ! mkdir $BACKUPDIR ; then
echo -e "Cannot create backup directory: $BACKUPDIR\n"
exit 2
fi
fi
echo Starting at `date "+%Y-%m-%d %H:%M:%S"`
echo -e -n "Dumping globals...\t\t"
$PG_DUMPALL -U postgres --globals-only > $BACKUPDIR/pg_globals.sql
echo "done."
for db in `$PSQL -U postgres -d template1 -t -c "SELECT datname FROM pg_catalog.pg_database WHERE datname "\!"~ 'template(0|1)';"`
do
echo -n -e "Dumping database $db...\t\t"
$PG_DUMP -U postgres --format=c $db > $BACKUPDIR/$db.dump
echo "done."
done
echo Ended at `date "+%Y-%m-%d %H:%M:%S"`
[...]
--
Milen A. Radev
From | Date | Subject | |
---|---|---|---|
Next Message | Stefano Nichele | 2009-02-01 16:12:34 | last_autovacuum field |
Previous Message | Cliff Pratt | 2009-01-31 23:47:53 | Re: [GENERAL] Encoding problem using pg_dumpall |
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2009-02-01 01:11:58 | Re: Indices types, what to use. Btree, Hash, Gin or Gist |
Previous Message | Kevin Murphy | 2009-02-01 00:52:31 | Re: Indices types, what to use. Btree, Hash, Gin or Gist |