Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tuCPa-0051ni-AQ for pgsql-general@arkaria.postgresql.org; Mon, 17 Mar 2025 15:29:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tuCPZ-00Ei0h-01 for pgsql-general@arkaria.postgresql.org; Mon, 17 Mar 2025 15:29:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tuCPY-00Ei0Y-LY for pgsql-general@lists.postgresql.org; Mon, 17 Mar 2025 15:29:52 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tuCPW-003LMK-2O for pgsql-general@lists.postgresql.org; Mon, 17 Mar 2025 15:29:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 52HFTave4009721; Mon, 17 Mar 2025 11:29:36 -0400 From: Tom Lane To: Sylvain Cuaz cc: pgsql-general@lists.postgresql.org Subject: Re: Restoring only a subset of schemas In-reply-to: <7d869dac-5fe0-488c-a7a1-436b1d939057@ilm-informatique.fr> References: <7d869dac-5fe0-488c-a7a1-436b1d939057@ilm-informatique.fr> Comments: In-reply-to Sylvain Cuaz message dated "Mon, 17 Mar 2025 15:57:04 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4009719.1742225376.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 17 Mar 2025 11:29:36 -0400 Message-ID: <4009720.1742225376@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sylvain Cuaz writes: > =C2=A0=C2=A0=C2=A0 Now if I want to restore from a full dump of this DB= , but with only one "cXXX" and the "Common" = > schema : > - if I pass --create --schema=3DCommon, then the CREATE SCHEMA is missin= g, i.e. it only emits data = > inside "Common" and the restore fails. > - if I could pass --create --exclude-schema=3D'c*' (fictional notation a= s patterns are only recognized = > by pg_dump), then all schemas would be created, with no data inside exce= pt for "Common". Creating = > all schemas is a waste of time, but more importantly would make restorin= g other schemas more = > difficult (e.g. rows should be inserted before creating foreign keys). In general, the solution for edge-case restore selection needs is to make a list of the dump's contents with "pg_restore -l", edit out what you don't want using any method you like, then use the edited list with "pg_restore -L". While I'd be in favor of improving pg_restore to accept wild-card patterns, I'm very hesitant to start inventing new kinds of selection switches for it. The interactions between such switches would be a mess. regards, tom lane