Re: Dump database more than 1 flat file

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "A(dot)Burbello" <burbello3000(at)yahoo(dot)com(dot)br>
Cc: Postgres Adm List <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Dump database more than 1 flat file
Date: 2007-12-18 01:05:11
Message-ID: 20071218010511.GE24103@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

A.Burbello wrote:

> If doesn't have another way, how can I put the
> "header" in the begin of file without open?
> With "cat >>" command I put in the end.

Don't -- you can put the header in a separate file and do something like

(cat header-file ; cat split-1 ; cat tail-file ) | psql

lather, rinse, repeat. (Each split-N file would be an output file from
split). I'm not sure if you also need the tail-file containing the \.
The parens tell the shell to execute all those commands and send the
output of all of them into the single psql process.

Of course you can automate it further, once you've copied all the DVDs
into a directory in the destination server:

for file in split-*; do
( cat header-file ; cat $file ; cat tail-file ) | psql
done

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tena Sakai 2007-12-18 03:03:44 Re: How would I "close" a atble?
Previous Message Phillip Smith 2007-12-18 01:01:20 Re: Dump database more than 1 flat file