On Mon, 06 Nov 2006, Roman Neuhauser wrote:
> # tometzky@batory.org.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:
> > [snip]
> > 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
It won't work if a database name have white space as first or last
letter... Or when database name has a newline somewhere (also
possible). It's hard to do it right so I did it simply wrong :-)
The way to do it right would be somehow forcing psql to output rows
separated by nulls ("\0") and use "xargs --null -i". But I don't know
how to do it.
Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh