Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnkL3-0008VB-PC for pgsql-admin@arkaria.postgresql.org; Wed, 17 Jul 2019 13:51:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnkL1-0004d0-Lr for pgsql-admin@arkaria.postgresql.org; Wed, 17 Jul 2019 13:51:19 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnkL1-0004c6-9V for pgsql-admin@lists.postgresql.org; Wed, 17 Jul 2019 13:51:19 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnkKu-0001aq-Bc for pgsql-admin@postgresql.org; Wed, 17 Jul 2019 13:51:18 +0000 Received: by mail-qk1-x734.google.com with SMTP id m14so17470745qka.10 for ; Wed, 17 Jul 2019 06:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+q4rrHlUbCRH/dguRSVlPj3QmRgnE+w1Yb/0oJRf1g4=; b=Ohkm0YY3clUNdds3UFEpBLaFyhllrmDjWy8UO0QiLy4TNv4et9i0x5KGZuhUf/fU5P nJa7FvM2PhPK4PSwbOsBrNplJgEfounkR20uAypN+eRSQy3obQcFZ01jEA4IcUea/Zxs 3kTo0C+XFy283vB3pUcduL/Qj9B2CMbq7AeVt7vkBkaqra8VvkztyQFad+fHgWn0NSOT jGg3lKTPd9Z/PfTsVr/mS8/pDhPJtpqyrulywUhnLtiz5dMXItZ61+Ts39vyUMVwvUCK 8JEG1EH1EGE6GVYR5oEb50kck3hReMeoWmaz6MVA146vulcHKYTcHdH0dTqHINHE3UVG qkkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+q4rrHlUbCRH/dguRSVlPj3QmRgnE+w1Yb/0oJRf1g4=; b=WLwa0vC8S6Gyj1RhByNC06+ITVqNBThpmphGy7dFg1MlBJ08q2J/5FAsyPPcBZCCLK puDtDMpwKOvLLCk8tb2DJvrZS1ahsd5iISygOdainK8XfF//CGoq5xr+GClCsnGlBdFY uBs9RnBuZaryu8iYbVcAO6/y4uj/y+26iDr1o7RWWRbC1DQlXEXxNDg7vjCe3k//sE9b QZNFCENyUjxO4ccb3XRxVyvzuvV7u5kNSB9OEOWQEYZa4lGlYL1Rt1Vn9zJUf2vgMgCC 7vqFyFPopFm/92GTjKmmCla/up5jNrMMbyfbgWJ0+VkHdFFKYv9PeX61r9R9xBWUSwCg 8rmQ== X-Gm-Message-State: APjAAAX3zRMfapneV77Ot0M/d4k1O8qhZrbJ/ZWIvQRzFEhWlxwk9B5Z yCyjgWDKqrJJcSjyIGVcbII= X-Google-Smtp-Source: APXvYqwxDJAdGAFB4oWmP3MrVcvYVdqbtR+NsCXvOdxkcD3U6C2oGbiGskaVU356bDaEd71fOfhttg== X-Received: by 2002:a05:620a:35e:: with SMTP id t30mr25062753qkm.1.1563371469620; Wed, 17 Jul 2019 06:51:09 -0700 (PDT) Received: from ?IPv6:2600:1003:b02f:facd:e9da:7aa:c864:9b73? ([2600:1003:b02f:facd:e9da:7aa:c864:9b73]) by smtp.gmail.com with ESMTPSA id g10sm10483117qkk.91.2019.07.17.06.51.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 06:51:09 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-B3883887-5115-4FCA-86EA-141BE6276B32 Mime-Version: 1.0 (1.0) Subject: Re: pg_restore and the -C flag From: John Scalia X-Mailer: iPhone Mail (16F203) In-Reply-To: Date: Wed, 17 Jul 2019 09:51:08 -0400 Cc: pgsql-admin Content-Transfer-Encoding: 7bit Message-Id: References: <4C9267A4-5A07-4FC0-B331-40EA95959534@gmail.com> To: Keith List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-B3883887-5115-4FCA-86EA-141BE6276B32 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks, Keith. I reread the documentation, and I guess that earlier, I wasn=E2= =80=99t awake enough to comprehend it. It=E2=80=99s all working now. Sent from my iPhone > On Jul 17, 2019, at 9:19 AM, Keith wrote: >=20 >=20 >=20 >> On Wed, Jul 17, 2019 at 8:43 AM John Scalia wrot= e: >> Hi all, >>=20 >> =46rom what I=E2=80=99m reading on www.postgresql.org, the -C option for p= g_restore is supposed to create the database before restoring into it, but h= ere=E2=80=99s my command line:=20 >>=20 >> pg_restore -p 5432 -C -d restored_db recovery.dmp >>=20 >> The dmp file was created with pg_dump using=20 >>=20 >> pg_dump -p 5432 -F c orig_db > recovery.dmp. >>=20 >> Pg_restore errors saying the database does not exist. Yes, I know that po= rt 5432 is the default, but not all of our databases are. So, do I have any= options wrong with either utility? Or why is this happening? I=E2=80=99m ju= st trying to document a recovery procedure and testing my documentation. >> =E2=80=94 >> Jay >>=20 >> Sent from my iPhone >>=20 >=20 > I suspect the name your feeding to -d is the one you're trying to create? Y= ou still have to tell pg_restore to connect to a database that actually exis= ts so it can log in to create one. So try passing "postgres" to the -d optio= n. Or connect as you usually do with psql and run \l to see what databases a= lready exist and connect to one of those. >=20 > Keith >=20 --Apple-Mail-B3883887-5115-4FCA-86EA-141BE6276B32 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks, Keith. I reread the documentation, a= nd I guess that earlier, I wasn=E2=80=99t awake enough to comprehend it. It=E2= =80=99s all working now.

S= ent from my iPhone

On Jul 17, 2019, at 9:19 AM, Ke= ith <keith@keithf4.com> wrote= :

<= div dir=3D"ltr">

On Wed, Jul 17, 2019 at 8:43 AM John Scalia <jayknowsunix@gmail.com> wrote:
Hi all,

=46rom what I=E2=80=99m reading on www.postgresql.org, the -C option for p= g_restore is supposed to create the database before restoring into it, but h= ere=E2=80=99s my command line:

pg_restore -p 5432 -C -d restored_db recovery.dmp

The dmp file was created with pg_dump using

pg_dump -p 5432 -F c orig_db > recovery.dmp.

Pg_restore errors saying the database does not exist. Yes, I know that port 5= 432 is the default, but not all of our databases are.  So, do I have an= y options wrong with either utility? Or why is this happening? I=E2=80=99m j= ust trying to document a recovery procedure and testing my documentation. =E2=80=94
Jay

Sent from my iPhone


I suspect the name your feeding to -d i= s the one you're trying to create?=20 You still have to tell pg_restore to connect to a database that actually exi= sts so it can log in to create one. So try passing "postgres" to the -d option. Or connect as you usually do wit= h psql and run \l to see what databases already exist and connect to one of t= hose.

Keith

= --Apple-Mail-B3883887-5115-4FCA-86EA-141BE6276B32--