Re: Setting privilegies from one DB to another - Mailing list pgsql-novice

From Brent Dombrowski
Subject Re: Setting privilegies from one DB to another
Date
Msg-id 3E93D1A0-A47C-4CD5-BD07-C2E68AE09591@gmail.com
Whole thread Raw
In response to Setting privilegies from one DB to another  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-novice
On Aug 17, 2011, at 6:43 AM, JORGE MALDONADO wrote:

> I am using a database in a development PC and in a test server, it is the
> same in both. Changes are first made in the development PC and applied to
> the test server later. Actually, the modifications made to the DB in my
> development PC are related to privilegies; I set them for the 6 group roles
> in every object (database, schema, tablespace, tables, sequences). Now, it
> is time to get them to the test server but it would be time consuming if I
> do it one at a time and also error prone. Is there a way to "backup" only
> privilegies from one DB and "restore" them to another one?
>
> With respect,
> Jorge Maldonado

pg_dumpall has options for globals or roles only (depending on the version). Take a look at the Postgres Manual for
yourversion (http://www.postgresql.org/docs/manuals/). It can be found under Server Administration -> Backup and
Restore.The output will be a plain text file that you can feed into your favorite client. This will get all the roles
andpasswords. 

As far as the privileges on each table, etc., that may take some work. I know a dump of the schema only will include
thatinfo. You may have to do that and then chop out all the other statements. I recently migrated a db and in 9.0.4 the
dumputilities put all the privileges in one section. A bit of copy and paste could get what you need.  I've seen
optionsfor no privileges, but have not seen an option for privileges only. Look into the options for pg_dump for just
onedatabase. 

Brent.


pgsql-novice by date:

Previous
From: JORGE MALDONADO
Date:
Subject: Setting privilegies from one DB to another
Next
From: Robert Frantz
Date:
Subject: How to restore an entire server from a .sql file created with PGAdmin Backup Server?