Re: Dump all databases to corresponding files

From: Tomasz Ostrowski <tometzky(at)batory(dot)org(dot)pl>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Dump all databases to corresponding files
Date: 2006-11-06 11:26:43
Message-ID: 20061106112641.GC30751@batory.org.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-11-06 11:38:15 Re: postmaster slowing down
Previous Message A. Kretschmer 2006-11-06 11:24:58 Re: Alias for tables/columns?