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 1gHe1M-0005H3-7T for pgsql-general@arkaria.postgresql.org; Wed, 31 Oct 2018 00:06:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHe1J-0004WP-GX for pgsql-general@arkaria.postgresql.org; Wed, 31 Oct 2018 00:06:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHe1H-0004WE-G5 for pgsql-general@lists.postgresql.org; Wed, 31 Oct 2018 00:06:01 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHe15-0007Ks-QA for pgsql-general@postgresql.org; Wed, 31 Oct 2018 00:05:58 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5A85122081; Tue, 30 Oct 2018 20:05:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 30 Oct 2018 20:05:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=y AvrfyoH2Cv/vvymUyAcgOEhmasJP56hnpBgZ81AC3w=; b=CDPIVrogFy3n9zDDk VStwB5SA4Lc8r1Cs+gJBXlV/WnyvIPlQzpkm07bEvo01fvfAJN7SvYeMpuwnXnBK a3TnJLUaQ3j6y0uxucmDQat/pSCbixkWCHqOojzFRsOGxKQdjvMdeNv4KBhAE0x7 kG8yorTE2KbK7JmlAXGE/QNPuUNy7oyiVJIgZjK5CvX9VaJGB+2TnRqCYNnQldNK Qlepgunr3Vc+hUty75M40pdDTnjuTNyrgkPWRpKqiQDE1UjOI8u3+p+Xrk/RDXQf G7jXoGUNauzST4+e754NyBmfkWK6NvQ2lA+QeeLtKYxNqK2bgBmdashs/BNhCYId GxmTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=yAvrfyoH2Cv/vvymUyAcgOEhmasJP56hnpBgZ81AC 3w=; b=bBQoKQtKTowxKOt3JvNdq9QyFZTbxcsBRd3d6ghHhjPivmoKKfEHscQ9v dhxEzKbxIlf0ZTtx4rKvrcDhDqdkQ6duRzKtFEI/C+7qYPNhyamZqZTcFhSHTrCf sRlGH23DwuT5cXBbz2RRhrfwr061CHSqsK7kkdMpOUAtd1i78gXFEyy9VzX+XSkB tiSI91bOLKLzovL/AfOTYD6w5nXmKWXOhsOYHClbvKifw6fbNEbPXEw7WFD/Rb2Z /KZFmADA9aLPsb9NhptQlVVt0bBFPVXTM143Nnccwu5OowFTxFxZ7iIDX1gZwhQs 9/9GaLPJqgiYEH+GGtw04uj3wK4jw== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 74129E4511; Tue, 30 Oct 2018 20:05:45 -0400 (EDT) Subject: Re: pg_restore to new database wants to wipe out the old database? To: Ron , pgsql-general References: <4a6e3243-7fcd-e7b3-4279-ce57bc5cf5ac@gmail.com> <8271fb47-8f04-a02b-2927-e475659274dd@gmail.com> From: Adrian Klaver Message-ID: <20bbf0a7-c4f2-c514-b59e-c33c891c784c@aklaver.com> Date: Tue, 30 Oct 2018 17:05:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <8271fb47-8f04-a02b-2927-e475659274dd@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 > > 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