pg_dumpall --roles-only > roles.sql

Category: Databases & SQL

pg_dumpall --roles-only > roles.sql

Back up only roles and permissions

Dumps cluster-wide roles, including passwords and memberships, without any database data. Handy for replicating authentication on a new server. Related: pg_dumpall --globals-only adds tablespaces.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.