Re: How to modify dump files created by pg_dump

From: 任洪彩 <qdurenhongcai(at)163(dot)com>
To: rod(at)iol(dot)ie
Cc: pgsql-general(at)postgresql(dot)org, hongcai(dot)ren(at)nsn(dot)com
Subject: Re: How to modify dump files created by pg_dump
Date: 2013-06-05 02:02:04
Message-ID: 1c5667b2.410b.13f1211d08d.Coremail.qdurenhongcai@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
Yes, you are right.
But -d option not suitable for me. Because our flatform use -C option and -d template1 option to create the database described in the dump file to restore the dump file.

The whole command like this:
# /opt/nokiasiemens/SS_Postgres/bin/pg_restore -C -h CFPU-0 -p 5433 -U _qnrnwdbman -d template1 -e -v /root/horen/rnwdump/DBRNWHSB.pgdump

在 2013-06-04 23:40:50,"Raymond O'Donnell" <rod(at)iol(dot)ie> 写道:
>On 04/06/2013 09:44, 任洪彩 wrote:
>> Hi, guys
>>
>> I have met a problem that do confused me.
>>
>> I created a dump file by pg_dump from database named "DBRNWHSB" with
>> parameters -b -o -Fc -Z 0.
>> As you know, at the beginning of the dump file contains some SQL
>> statements for create the database "DBRNWHSB".
>>
>> So here comes the question, I want let these SQL statements to create
>> another database, e.g. named "myDB". In that case, when restore the dump
>> i can restore the modified dump file with "-C" that "myDB" can be founded.
>>
>> I have tried to modify the dump file manually. But the dump file may
>> caused invalid.
>>
>> # /opt/nokiasiemens/SS_Postgres/bin/pg_restore -C -h CFPU-0 -p 5433 -U
>> _qnrnwdbman -d template1 -e -v /root/horen/rnwdump/DBRNWHSB.pgdump
>> pg_restore: connecting to database for restore
>> pg_restore: implied data-only restore
>>
>> I wonder is there any way to modify the dump file after create or i can
>> specify the database name when dump?
>
>I think you're asking for trouble trying to modify the dump file manually.
>
>If I understand, you want to restore into a database with a different
>name to the original one, is that correct? If so, then simply create the
>database manually, then restore into it with the -d option:
>
> pg_restore -d <my-other-database> <dump-file>
>
>HTH,
>
>Ray.
>
>--
>Raymond O'Donnell :: Galway :: Ireland
>rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Panneerselvam Posangu 2013-06-05 08:29:39 Synonyms in PostgreSQL 9.2.4
Previous Message Sergey Konoplev 2013-06-05 00:58:58 Re: vacuum_cost_delay and autovacuum_cost_delay