Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzm6T-0004Fb-Lq for pgsql-admin@arkaria.postgresql.org; Sat, 03 Jul 2021 20:19:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lzm6R-0007Gx-TI for pgsql-admin@arkaria.postgresql.org; Sat, 03 Jul 2021 20:19:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzm6R-0007Gp-Kp for pgsql-admin@lists.postgresql.org; Sat, 03 Jul 2021 20:19:03 +0000 Received: from aws.mailpen.com ([52.43.43.172] helo=aws2.mailpen.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzm6N-00048M-6Q for pgsql-admin@postgresql.org; Sat, 03 Jul 2021 20:19:02 +0000 Received: from [172.20.70.208] (unknown [50.35.114.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by aws2.mailpen.com (Postfix) with ESMTPSA id CB9FBC5F0CB for ; Sat, 3 Jul 2021 13:18:57 -0700 (PDT) To: pgsql-admin@postgresql.org From: "Dean Gibson (DB Administrator)" Subject: The trap when using pg_dumpall Organization: UltiMeth Systems Message-ID: <24285551-fa0c-0b38-5380-a58aca27a8a9@mailpen.com> Date: Sat, 3 Jul 2021 13:18:57 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------C545AFEB0B26780D9042DFCB" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------C545AFEB0B26780D9042DFCB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Years ago, I started backing up my table data in individual groups (typically SCHEMAs).  More recently, I have also been backing up the entire cluster using pg_dumpall. Today I thought: /Why not stop the dumps of individual groups?  Why not use continue to dump with pg_dumpall, & then use pg_restore to restore *all or just portions* of the database, as needed?/ That sounded good until I did a bit of research.  Despite this site https://www.postgresqltutorial.com/postgresql-restore-database/ saying that you could use pg_restore with pg_dumpall, the authoritative documentation says that you can't. So, assuming that's true, what is the best way to accomplish what I want?  I see no effective way of filtering out individual SCHEMAs when restoring from the output of a pg_dumpall.  That means: 1. Using pg_restore, which has the capability of filtering the restore. 2. Using pg_dump with archive output. Unfortunately, as far as I know, pg_dump doesn't dump roles & possibly other data that I need.  I presently have script files that I keep updated (hopefully) in parallel, for the compute manual recreation of the database, but there's nothing like backing up up everything. So, here's my ultimate question(s): 1. Can I do a pg_dumpall to backup just the parts that pg_dump omits, & then be able to do a complete restore by restoring the non-data with psql, & then restoring the data with pg_restore? 2. If so, what are the appropriate options to pg_dumpall? I'm thinking the following will work, but an authoritative answer would be nice: pg_dumpall  -rs  (I don't use tablespaces) --------------C545AFEB0B26780D9042DFCB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Years ago, I started backing up my table data in individual groups (typically SCHEMAs).  More recently, I have also been backing up the entire cluster using pg_dumpall.

Today I thought:

Why not stop the dumps of individual groups?  Why not use continue to dump with pg_dumpall, & then use pg_restore to restore all or just portions of the database, as needed?

That sounded good until I did a bit of research.  Despite this site https://www.postgresqltutorial.com/postgresql-restore-database/ saying that you could use pg_restore with pg_dumpall, the authoritative documentation says that you can't.

So, assuming that's true, what is the best way to accomplish what I want?  I see no effective way of filtering out individual SCHEMAs when restoring from the output of a pg_dumpall.  That means:

  1. Using pg_restore, which has the capability of filtering the restore.
  2. Using pg_dump with archive output.

Unfortunately, as far as I know, pg_dump doesn't dump roles & possibly other data that I need.  I presently have script files that I keep updated (hopefully) in parallel, for the compute manual recreation of the database, but there's nothing like backing up up everything.

So, here's my ultimate question(s):

  1. Can I do a pg_dumpall to backup just the parts that pg_dump omits, & then be able to do a complete restore by restoring the non-data with psql, & then restoring the data with pg_restore?
  2. If so, what are the appropriate options to pg_dumpall?

I'm thinking the following will work, but an authoritative answer would be nice:

pg_dumpall  -rs  (I don't use tablespaces)





--------------C545AFEB0B26780D9042DFCB--