niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » PostgreSQL
Dump all in several files
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
Frederic Massot
*nix forums beginner


Joined: 15 Mar 2005
Posts: 7

PostPosted: Tue Mar 15, 2005 3:35 pm    Post subject: Re: Dump all in several files Reply with quote

Alvaro Herrera wrote:
Quote:
On Tue, Mar 15, 2005 at 05:01:39PM +0100, Frederic Massot wrote:

[...]

You can obtain the list of databases for scripting with

psql -tlA | cut -d\| -f1


Great !!! Surprised)

Thank you.
--
==============================================
| FREDERIC MASSOT |
| http://www.juliana-multimedia.com |
| mailto:frederic@juliana-multimedia.com |
===========================Debian=GNU/Linux===

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Back to top
javier wilson
*nix forums beginner


Joined: 01 Mar 2005
Posts: 4

PostPosted: Tue Mar 15, 2005 3:32 pm    Post subject: Re: Dump all in several files Reply with quote

On Tue, 15 Mar 2005 12:15:39 -0400, Alvaro Herrera
<alvherre@dcc.uchile.cl> wrote:
Quote:
On Tue, Mar 15, 2005 at 05:01:39PM +0100, Frederic Massot wrote:
Lonni J Friedman wrote:
On Tue, 15 Mar 2005 16:43:01 +0100, Frederic Massot
frederic@juliana-multimedia.com> wrote:

Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

Maybe i'm just not following you, but why can't you just do:
pg_dump $DBNAME >$DB_NAME

where $DB_NAME is the name of each database on the box?


This script is called in a crontab the every day at 6 o'clock in the
morning.

You can obtain the list of databases for scripting with

psql -tlA | cut -d\| -f1


i didn't know that. very nice. try:

psql -Upostgres -tlA |cut -d\| -f1|xargs -i pg_dump -Upostgres -f
'{}'.dump.sql '{}'


javier

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Back to top
Alvaro Herrera
*nix forums Guru Wannabe


Joined: 11 Mar 2005
Posts: 174

PostPosted: Tue Mar 15, 2005 3:15 pm    Post subject: Re: Dump all in several files Reply with quote

On Tue, Mar 15, 2005 at 05:01:39PM +0100, Frederic Massot wrote:
Quote:
Lonni J Friedman wrote:
On Tue, 15 Mar 2005 16:43:01 +0100, Frederic Massot
frederic@juliana-multimedia.com> wrote:

Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

Maybe i'm just not following you, but why can't you just do:
pg_dump $DBNAME >$DB_NAME

where $DB_NAME is the name of each database on the box?


This script is called in a crontab the every day at 6 o'clock in the
morning.

You can obtain the list of databases for scripting with

psql -tlA | cut -d\| -f1

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"Si quieres ser creativo, aprende el arte de perder el tiempo"

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Back to top
javier wilson
*nix forums beginner


Joined: 01 Mar 2005
Posts: 4

PostPosted: Tue Mar 15, 2005 3:14 pm    Post subject: Re: Dump all in several files Reply with quote

On Tue, 15 Mar 2005 17:01:39 +0100, Frederic Massot
<frederic@juliana-multimedia.com> wrote:
Quote:
Lonni J Friedman wrote:
On Tue, 15 Mar 2005 16:43:01 +0100, Frederic Massot
frederic@juliana-multimedia.com> wrote:

Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

[...]

Maybe i'm just not following you, but why can't you just do:
pg_dump $DBNAME >$DB_NAME

where $DB_NAME is the name of each database on the box?


This script is called in a crontab the every day at 6 o'clock in the
morning.

i have a /etc/backup/data.pgsql where i list all databases
i want to dump, then a script in /etc/cron.daily reads this file
and call pg_dump:
pg_dump -U postgres $1>$1.dump.sql

javier

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Back to top
Frederic Massot
*nix forums beginner


Joined: 15 Mar 2005
Posts: 7

PostPosted: Tue Mar 15, 2005 3:01 pm    Post subject: Re: Dump all in several files Reply with quote

Lonni J Friedman wrote:
Quote:
On Tue, 15 Mar 2005 16:43:01 +0100, Frederic Massot
frederic@juliana-multimedia.com> wrote:

Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

[...]

Maybe i'm just not following you, but why can't you just do:
pg_dump $DBNAME >$DB_NAME

where $DB_NAME is the name of each database on the box?


This script is called in a crontab the every day at 6 o'clock in the
morning.

--
==============================================
| FREDERIC MASSOT |
| http://www.juliana-multimedia.com |
| mailto:frederic@juliana-multimedia.com |
===========================Debian=GNU/Linux===

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Back to top
Lonni J Friedman
*nix forums beginner


Joined: 03 Mar 2005
Posts: 28

PostPosted: Tue Mar 15, 2005 2:54 pm    Post subject: Re: Dump all in several files Reply with quote

On Tue, 15 Mar 2005 16:43:01 +0100, Frederic Massot
<frederic@juliana-multimedia.com> wrote:
Quote:
Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

With version 7.3 of PostgreSQL (and the following) the data are not
recorded any more in a repertory with the name of the database, but with
the OID of the basebase.

Do you know how I can adapt this script?

If a developer of pg_dumpall reads this post, is it possible to add to
the command pg_dumpall an option to record one database per file?

Regards.

#! /bin/bash
#
for p in $(find /var/lib/postgres/data/base/ -type d -print -mindepth 1
-maxdepth 1 )
do
base=`basename "$p"`
pg_dump -d -f /var/backup/postgresql/dump_$base $base
done

Maybe i'm just not following you, but why can't you just do:
pg_dump $DBNAME >$DB_NAME

where $DB_NAME is the name of each database on the box?


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman netllama@gmail.com
LlamaLand http://netllama.linux-sxs.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Back to top
Frederic Massot
*nix forums beginner


Joined: 15 Mar 2005
Posts: 7

PostPosted: Tue Mar 15, 2005 2:43 pm    Post subject: Dump all in several files Reply with quote

Hi,

On the PostgreSQL 6.5 server I use this shell script (see below) for the
backup all of the database in several files, one file per database.

With version 7.3 of PostgreSQL (and the following) the data are not
recorded any more in a repertory with the name of the database, but with
the OID of the basebase.

Do you know how I can adapt this script?

If a developer of pg_dumpall reads this post, is it possible to add to
the command pg_dumpall an option to record one database per file?

Regards.


#! /bin/bash
#
for p in $(find /var/lib/postgres/data/base/ -type d -print -mindepth 1
-maxdepth 1 )
do
base=`basename "$p"`
pg_dump -d -f /var/backup/postgresql/dump_$base $base
done

--
==============================================
| FREDERIC MASSOT |
| http://www.juliana-multimedia.com |
| mailto:frederic@juliana-multimedia.com |
===========================Debian=GNU/Linux===

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 8:02 am | All times are GMT
navigation Forum index » Databases » PostgreSQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts howto log in from one bsd-server to another and move file... Tobias Steer FreeBSD 3 Thu Jul 20, 2006 10:02 am
No new posts Binary Files Ronin C++ 8 Wed Jul 19, 2006 3:12 pm
No new posts Bug#378877: ITP: libsvm-doc -- documentation and example ... Rudi Cilibrasi devel 0 Wed Jul 19, 2006 1:50 pm
No new posts Bug#378873: ITP: libsvm0-dev -- development files for Lib... Rudi Cilibrasi devel 0 Wed Jul 19, 2006 1:20 pm
No new posts Bug#378866: ITP: libnanohttp1-dev -- header files for nan... Rudi Cilibrasi devel 0 Wed Jul 19, 2006 12:40 pm

Debt Consolidation | Recreation websites directory | Remortgages | Credit Card Application | Car Credit
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2227s ][ Queries: 20 (0.1060s) ][ GZIP on - Debug on ]