Dump and restore postgresql users (roles)

dump on source database: pg_dumpall -r > sourceroles.backup restore on target database: if postgresql is freshly installed you will have to switch to postgres user: sudo su postgres restore under postgres user: psql < sourceroles.backup...

psql quick help

All command can be followed by “mask” to show only some objects. tablespaces: list all tablespaces with sizes: \db+ ┬ádatabases: connect to some database: \c dbname list all: \l+ schemas: \dn+ users, roles: \dg+ extensions: list installed extensions: \dx...

Useful regular expressions

column contains some upper case letters: column ~ E'[[:upper:]]' column contains some lower case letters: column ~...