From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@postgresql.org
Subject: pg_restore to new database wants to wipe out the old database?
Date: Tue, 30 Oct 2018 17:08:35 -0500
Message-ID: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: pg_restore to new database wants to wipe out the old database?
In-Reply-To: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com>
References: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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