From: | Roman Neuhauser <neuhauser(at)sigpipe(dot)cz> |
---|---|
To: | Tomasz Ostrowski <tometzky(at)batory(dot)org(dot)pl> |
Cc: | CSN <cool_screen_name90001(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Dump all databases to corresponding files |
Date: | 2006-11-06 16:24:46 |
Message-ID: | 20061106162446.GF95663@dagan.sigpipe.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
# tometzky(at)batory(dot)org(dot)pl / 2006-11-06 12:26:43 +0100:
> On Sun, 05 Nov 2006, CSN wrote:
>
> > Anybody know of a script that dumps all databases into
> > corresponding dump files
>
> I've written this one in bash:
>
> #########################################################
> #!/bin/bash
>
> pg_dumpall -g > /var/lib/pgsql/backups/globals.sql
> for dbname in `psql -qXtc "
> select
> datname from pg_catalog.pg_database
> where datname<>'template0'
> " template1`
> do
> pg_dump -b -F t "$dbname" > "/var/lib/pgsql/backups/$dbname.dump"
> done
> #########################################################
>
> This would break if any database name has white space.
Why don't you use "while" then?
psql -qXtc "$query" template1 | while read dbname; do
pg_dump -b -F t "$dbname" > "/var/lib/pgsql/backups/$dbname.dump"
done
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
From | Date | Subject | |
---|---|---|---|
Next Message | William Leite Araújo | 2006-11-06 16:50:48 | Re: Schema search_path and views |
Previous Message | Roman Neuhauser | 2006-11-06 16:18:48 | Re: first steps in PhP and PostgreSQL |