From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: pg_restore to new database wants to wipe out the old database? |
Date: | 2018-10-31 00:05:44 |
Message-ID: | 20bbf0a7-c4f2-c514-b59e-c33c891c784c@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/30/18 3:25 PM, Ron wrote:
> On 10/30/2018 05:16 PM, David G. Johnston wrote:
>> On Tue, Oct 30, 2018 at 3:09 PM Ron <ronljohnsonjr(at)gmail(dot)com
>> <mailto:ronljohnsonjr(at)gmail(dot)com>> wrote:
>>
>> Hi,
>>
>> v9.6.9
>>
>> Why is pg_restore trying to drop my production database, when I
>> (think I) am telling it to create the new database "Molson"?
>>
>> Straight from the pg_restore documentation:
>> -C
>>
>> "When this option is used, the database named with |-d| is used only
>> to issue the initial |DROP DATABASE| and |CREATE DATABASE| commands.
>> All data is restored into the database name that appears in the archive."
>
> So I've got to explicitly CREATE DATABASE "Molson" and then
> pg_restore -d Molson Molson
No. The docs have an example that demonstrates:
https://www.postgresql.org/docs/9.6/static/app-pgrestore.html
To reload the dump into a new database called newdb:
$ createdb -T template0 newdb
$ pg_restore -d newdb db.dump
So(you will probably need to add appropriate -U to below):
createdb -T template0 "Molson"
pg_restore -d "Molson" proddb
>
>>
>> Also
>> " pg_restore -vcC --if-exists --jobs=8 -d postgres Molson "
>>
>> pg_restore [connection-option...] [option...] [filename]
>>
>> "Molson" is a file name; pg_restore doesn't use the file name aside
>> from finding where the data you want to restore is located.
>>
>> David J.
>>
>
> --
> Angular momentum makes the world go 'round.
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2018-10-31 01:50:19 | Re: Should pg 11 use a lot more memory building an spgist index? |
Previous Message | Nicolas Paris | 2018-10-30 23:08:00 | Full-text Search - Thesaurus relationships |