pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_restore to new database wants to wipe out the old database?
4+ messages / 3 participants
[nested] [flat]
* pg_restore to new database wants to wipe out the old database?
@ 2018-10-30 22:08 Ron <ronljohnsonjr@gmail.com>
2018-10-30 22:16 ` Re: pg_restore to new database wants to wipe out the old database? David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Ron @ 2018-10-30 22:08 UTC (permalink / raw)
To: pgsql-general
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"?
$ cd /backup
$ pg_dump -d proddb -j 8 -Fd --no-synchronized-snapshots -Z0 -v -f proddb 2>
proddb_pgdump.log
$ mv proddb Molson
$ pg_restore -vcC --if-exists --jobs=8 -d postgres Molson
pg_restore: connecting to database for restore
pg_restore: dropping DATABASE proddb
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 145485; 1262 16385 DATABASE
proddb TAP
pg_restore: [archiver (db)] could not execute query: ERROR: database
"proddb" is being accessed by other users
DETAIL: There are 3 other sessions using the database.
Command was: DROP DATABASE IF EXISTS "proddb";
pg_restore: processing item 145482 ENCODING ENCODING
pg_restore: processing item 145483 STDSTRINGS STDSTRINGS
pg_restore: processing item 145484 SEARCHPATH SEARCHPATH
pg_restore: processing item 145485 DATABASE proddb
pg_restore: creating DATABASE "proddb"
pg_restore: [archiver (db)] could not execute query: ERROR: database
"proddb" already exists
Command was: CREATE DATABASE "proddb" WITH TEMPLATE = template0
ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
Thanks
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_restore to new database wants to wipe out the old database?
2018-10-30 22:08 pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
@ 2018-10-30 22:16 ` David G. Johnston <david.g.johnston@gmail.com>
2018-10-30 22:25 ` Re: pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: David G. Johnston @ 2018-10-30 22:16 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general
On Tue, Oct 30, 2018 at 3:09 PM Ron <ronljohnsonjr@gmail.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."
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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_restore to new database wants to wipe out the old database?
2018-10-30 22:08 pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
2018-10-30 22:16 ` Re: pg_restore to new database wants to wipe out the old database? David G. Johnston <david.g.johnston@gmail.com>
@ 2018-10-30 22:25 ` Ron <ronljohnsonjr@gmail.com>
2018-10-31 00:05 ` Re: pg_restore to new database wants to wipe out the old database? Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 4+ messages in thread
From: Ron @ 2018-10-30 22:25 UTC (permalink / raw)
To: pgsql-general
On 10/30/2018 05:16 PM, David G. Johnston wrote:
> On Tue, Oct 30, 2018 at 3:09 PM Ron <ronljohnsonjr@gmail.com
> <mailto:ronljohnsonjr@gmail.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
>
> 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pg_restore to new database wants to wipe out the old database?
2018-10-30 22:08 pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
2018-10-30 22:16 ` Re: pg_restore to new database wants to wipe out the old database? David G. Johnston <david.g.johnston@gmail.com>
2018-10-30 22:25 ` Re: pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
@ 2018-10-31 00:05 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 4+ messages in thread
From: Adrian Klaver @ 2018-10-31 00:05 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; 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@gmail.com
>> <mailto:ronljohnsonjr@gmail.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.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2018-10-31 00:05 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30 22:08 pg_restore to new database wants to wipe out the old database? Ron <ronljohnsonjr@gmail.com>
2018-10-30 22:16 ` David G. Johnston <david.g.johnston@gmail.com>
2018-10-30 22:25 ` Ron <ronljohnsonjr@gmail.com>
2018-10-31 00:05 ` Adrian Klaver <adrian.klaver@aklaver.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox