Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHcBt-0000YJ-Ix for pgsql-general@arkaria.postgresql.org; Tue, 30 Oct 2018 22:08:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHcBq-0003TZ-0L for pgsql-general@arkaria.postgresql.org; Tue, 30 Oct 2018 22:08:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHcBp-0003TS-J0 for pgsql-general@lists.postgresql.org; Tue, 30 Oct 2018 22:08:45 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gHcBi-0003Iw-Qb for pgsql-general@postgresql.org; Tue, 30 Oct 2018 22:08:44 +0000 Received: by mail-ot1-x331.google.com with SMTP id m15so12698703otl.7 for ; Tue, 30 Oct 2018 15:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=4GoW/geyrkuOXbyDHMuMa/bsXQhmHO52olqrfvud27c=; b=Maq/ZtXVwQNMPnuPd+jzrNLjgnOtz+YMZ8XoAwNCVAAZ5Atv4i4BHOGMJmcdCJEeBF 7/OmbqIDyWUPC2f0/6XblXnalJX1KNZ8xLGMOyTGcGa5pcqouLxbEGTqmDjYxhemM+uw CdmR3+iNknnzfooPvpfLNtqm8NPTqaekSZ4Bx9rUWuRjrE85Qdf+4CxnuQL4eZLHcBS9 R+tpUQ3tIg2lrDQs1d/VtaiALxmHYu6vKiq2uqJ3mcu9/64e0+NL8Oqqp43K2sd12IF4 yu48UYoxegU5we+Ys/H5UAV5/Yp7/0h+kEcpRktBYpZKnPq0K1BlA8JeAfxS7H+cHHEM 73XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=4GoW/geyrkuOXbyDHMuMa/bsXQhmHO52olqrfvud27c=; b=Eha3neBg8nCflJO8brwRBbmnYjh4ku964EThXASJIzqaoCkt0qBvE4pz/eawYT1qWi aTFUoV39mt9EAQ9wpPLnUq5vQX6Kc8od0clkMMk9XOoc59sBAZGW9KftQcw1luP5kue4 jljEHV5V0Uj9wHf1GeZP5hehRYzWrrDGG24G1YU9w6m005eC6127/8leXckknPpNmagK MYsssrEepgKds5HF8jyR2LlrNZKFuMKjII9M3UHjlaKbjd4yEakgyfBosikTJ2LuL99L eJP9wYGMdbCC/MPj7W9VoOR6Mi+/wd5wBSEc7LQq5bcXLJhoRsf4vZZXvFZijFhcph1v ToHQ== X-Gm-Message-State: AGRZ1gI3uYP1v1BGW/oiS8bumWC3jdFD9WGQfkfWjrRw8VflAf6XYI1N 6HQZUUh2jgpNTfYKBETnZVJSuRQB X-Google-Smtp-Source: AJdET5eXhF33VRnWtHj8WkXSW+2GAE3dczJ8iGDL+6pZR2tNUFyu+2vW/YN6OUcZPcAMBlizShpbjw== X-Received: by 2002:a9d:ed1:: with SMTP id 75mr359773otj.137.1540937317049; Tue, 30 Oct 2018 15:08:37 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id c202-v6sm1667685oih.26.2018.10.30.15.08.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 15:08:36 -0700 (PDT) To: pgsql-general@postgresql.org From: Ron Subject: pg_restore to new database wants to wipe out the old database? Message-ID: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com> Date: Tue, 30 Oct 2018 17:08:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------2610B14BC6A9F106038056AC" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------2610B14BC6A9F106038056AC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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. --------------2610B14BC6A9F106038056AC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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.
--------------2610B14BC6A9F106038056AC--