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 1rfMwc-00HEeo-St for pgsql-admin@arkaria.postgresql.org; Wed, 28 Feb 2024 16:38:11 +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 1rfMwa-00C8x4-G8 for pgsql-admin@arkaria.postgresql.org; Wed, 28 Feb 2024 16:38:08 +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 1rfMwa-00C8ww-5R for pgsql-admin@lists.postgresql.org; Wed, 28 Feb 2024 16:38:08 +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.94.2) (envelope-from ) id 1rfMwS-001qg2-Gq for pgsql-admin@lists.postgresql.org; Wed, 28 Feb 2024 16:38:07 +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 41SGc0es2317288; Wed, 28 Feb 2024 11:38:00 -0500 From: Tom Lane To: David Barron cc: Pgsql-admin Subject: Re: Backup strategy In-reply-to: References: Comments: In-reply-to David Barron message dated "Wed, 28 Feb 2024 16:23:23 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2317286.1709138280.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Feb 2024 11:38:00 -0500 Message-ID: <2317287.1709138280@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Barron writes: > I'm responsible for a couple of databases that have constraints and inde= xes on most, if not all, of the tables, which means that the tables have t= o be backed up and restored in the correct order to take the constraints i= nto account. But pg_dump and pg_restore don't take that into account, so = when doing restores I was running into errors. Hopefully that is clear. Your statement is clear, but you have not provided any explanation of *why* pg_dump fails to cope with your database. It generally does manage to handle foreign key constraints without help. > The solution I found was to use the -section option with pg_dump, like t= his: Splitting up the dump is frequently counterproductive, so I have a feeling this isn't the best way to proceed. In any case, --section still emits all the same items in the same order, so it's not really likely to fix problems. Probably what masked the issue is your use of --disable-triggers. regards, tom lane