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 1j1eId-0005js-IN for pgsql-general@arkaria.postgresql.org; Tue, 11 Feb 2020 22:46:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j1eIc-0000ww-CL for pgsql-general@arkaria.postgresql.org; Tue, 11 Feb 2020 22:46:34 +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 1j1eIc-0000wp-2Z for pgsql-general@lists.postgresql.org; Tue, 11 Feb 2020 22:46:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j1eIZ-0002jJ-H9 for pgsql-general@postgresql.org; Tue, 11 Feb 2020 22:46:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01BMkKUu011492; Tue, 11 Feb 2020 17:46:20 -0500 From: Tom Lane To: "Andrus" cc: "pgsql-general" Subject: Re: How to restore roles without changing postgres password In-reply-to: <38D406CB287140A49F635258B634E072@dell2> References: <38D406CB287140A49F635258B634E072@dell2> Comments: In-reply-to "Andrus" message dated "Wed, 12 Feb 2020 00:26:50 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11490.1581461180.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 11 Feb 2020 17:46:20 -0500 Message-ID: <11491.1581461180@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Andrus" writes: > How to create backup script which restores all roles and role membership= s = > from other server without changing postgres user password. [ shrug... ] Edit the command(s) you don't want out of the script. This seems like a mighty random requirement to expect pg_dump to support out-of-the-box. I wonder though if there's a case for making that easier by breaking up the output into multiple ALTER commands. Right now you get something like CREATE ROLE postgres; ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLI= CATION BYPASSRLS PASSWORD 'md5128f0d64bfb424d132c3305b3057281c'; but perhaps we could make it print CREATE ROLE postgres; ALTER ROLE postgres WITH SUPERUSER; ALTER ROLE postgres WITH INHERIT; ALTER ROLE postgres WITH CREATEROLE; ALTER ROLE postgres WITH CREATEDB; ALTER ROLE postgres WITH LOGIN; ALTER ROLE postgres WITH REPLICATION; ALTER ROLE postgres WITH BYPASSRLS; ALTER ROLE postgres WITH PASSWORD 'md5128f0d64bfb424d132c3305b3057281c'; That would make scripted edits a bit easier, and it'd also make the output a bit more cross-version portable, eg if you try to load the latter into a version without BYPASSRLS, the rest of the commands would still work. regards, tom lane