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 1gHcSf-0001GI-N9 for pgsql-general@arkaria.postgresql.org; Tue, 30 Oct 2018 22:26:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHcSd-0000U8-Ke for pgsql-general@arkaria.postgresql.org; Tue, 30 Oct 2018 22:26:07 +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 1gHcSd-0000U1-6g for pgsql-general@lists.postgresql.org; Tue, 30 Oct 2018 22:26:07 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gHcSW-0003j0-Hj for pgsql-general@postgresql.org; Tue, 30 Oct 2018 22:26:06 +0000 Received: by mail-oi1-x233.google.com with SMTP id k64-v6so11915555oia.13 for ; Tue, 30 Oct 2018 15:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=pdTrfWrXmjsQlxmyopKDt8XhJBzPh2yZx3bnWgPwJc0=; b=X7j+ksLZCXj/1TUhDthl8MdBQ/t2AY9yaeI9T7vClJaR/EHbc03EmljRtbTCdEJRcn fWWMbig+gy8KsBcZ/Dgvx9uMO8YAwYWzy/6Fb64CcnxVxlsSXwYBB29Y3f3C/EaDgNyV E5BAUANhH7ONZVJsSlnWkz0si0vqlh9zC7vTQdcjY9bw/d7uahPLfUKs3/8tAWDKKxT9 //numnSxBtUytVR4LCMDsZbQKV49HKoZ+XhaBd2SH+eqNDE6toJ/2EVcuXlHWNkSMD+j NtBPPO9nLzixAR2h9zf870pnnaJFaErtf+8xbAE0GlMsxnu2Q0Qa27l7WAQVHhMSdLPi jinA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=pdTrfWrXmjsQlxmyopKDt8XhJBzPh2yZx3bnWgPwJc0=; b=oXTy0asHUymYWgezghSkbLVQs49YI+9AUYr3x7em2O2g81ZhNUCnF5DpI+KKedWb62 VcdatL+SYmSsgIKu1VUkwRFWTyJPy3oLdGvbsw1mcgd2WZ6ZVfLYbjFFlIZtXxN2dPAo 62Fv3GPvpNNcazKyKF+VWWmJDZihJYPRknI1/wW2s4jO8JyXM69YnQSd2u8qd5LzdHUp wg7TcgVE/PBlPqi7zCkKSxHP/TFI9wxQG+qxUmPR9vqB/2c2kA297yvjJwiILCOA4dwF LIBhaaohlm+f0YON667kLjyD5qGgGXjaIEY+wUctBJKiYIDh7z81HLJYqP5v2Du+rxIb PWHA== X-Gm-Message-State: AGRZ1gKUkThrQcmJhK5aXQ4Dl+nLql2tZgCsqPLB7GRWRc4HeGyNHMOd nGlIdwWNzWM/e5T0Rto+KndR/orA X-Google-Smtp-Source: AJdET5fiaggCacMbsc/7873SdmKOSEPrOUi6HSLK5qlf7ybsUU9+27gCZpcaJBGEWz7h2C7WETY0fA== X-Received: by 2002:aca:c0c1:: with SMTP id q184-v6mr342081oif.353.1540938359109; Tue, 30 Oct 2018 15:25:59 -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 l6-v6sm1055370oia.46.2018.10.30.15.25.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 15:25:58 -0700 (PDT) Subject: Re: pg_restore to new database wants to wipe out the old database? To: pgsql-general References: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com> From: Ron Message-ID: <8271fb47-8f04-a02b-2927-e475659274dd@gmail.com> Date: Tue, 30 Oct 2018 17:25:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F1A2F74544EBCCE49B768711" 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. --------------F1A2F74544EBCCE49B768711 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 10/30/2018 05:16 PM, David G. Johnston wrote: > On Tue, Oct 30, 2018 at 3:09 PM Ron > 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. --------------F1A2F74544EBCCE49B768711 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 10/30/2018 05:16 PM, David G. Johnston wrote:
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."

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.
--------------F1A2F74544EBCCE49B768711--