Search Postgresql Archives

Re: Dump all databases to corresponding files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 06 Nov 2006, Roman Neuhauser wrote:

> # tometzky@xxxxxxxxxxxxx / 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux