Re: How to restore roles without changing postgres password

From: Justin <zzzzz(dot)graf(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrus <kobruleht2(at)hot(dot)ee>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to restore roles without changing postgres password
Date: 2020-02-11 23:04:02
Message-ID: CALL-XeM1ruiC+mFgkORtz7u-O1hnjqYB1jMRG6r61RyCoDdckA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-general

HI Tom

Not a bad idea, would want to extend this to all the roles on the server
not just postgres

I've edited the global dump many times removing/editing table spaces,
comment old users, etc..

On Tue, Feb 11, 2020 at 5:46 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "Andrus" <kobruleht2(at)hot(dot)ee> writes:
> > How to create backup script which restores all roles and role
> memberships
> > 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
> REPLICATION 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
>
>
>

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Jonathan S. Katz 2020-02-12 03:56:27 Re: Duplicating website's formatting in local doc builds
Previous Message Tom Lane 2020-02-11 22:46:20 Re: How to restore roles without changing postgres password

Browse pgsql-general by date

  From Date Subject
Next Message Vikram Sah 2020-02-12 01:17:54 Re: Function not imported in Entity Framework
Previous Message Tom Lane 2020-02-11 22:46:20 Re: How to restore roles without changing postgres password