All HowTo's PostgreSQL

How to Copy Postgresql Role Permissions From One Server to Another

This article shows how to copy role permissions from one server to another. In other words, if you’re moving a database from one server to another and you want permissions to come across too, you’ll be interested in this article.

If you have trouble with this tutorial, make sure you run these commands as the ‘postgres’ user.

On the “source” server, run this:

pg_dumpall -g > ~/roles.sql

On the “target” server, run this:

psql -U postgres -f ~/roles.sql

The above is enough in most situations. However, if you need to specify a specific version of Postgresql, consider the following instead of the above examples:

On the “source” server, run this:

/usr/pgsql-9.4/bin/pg_dumpall -g > ~/roles.sql

On the “target” server, run this:

/usr/pgsql-9.4/bin/psql -U postgres -f ~/roles.sql

Leave a Reply

Your email address will not be published. Required fields are marked *