Postgresql – Schema Dump Without User Mapping Passwords

pg-dumppostgresqlpostgresql-9.5

Is it possible to do a pg_dump --schema-only of the database schema but not include any username/password combinations that are in user mappings?

For example, I would like items such as the following to not be put in the dump:

CREATE USER MAPPING FOR greg SERVER db_name OPTIONS (
    password 'supersecret',
    username 'bobs_uncle'
);

Best Answer

The only thing I can think of is to create a single-purpose non-super user and grant them read access to all the objects in the database. Then run pg_dump connected as that user. Perhaps not the most elegant solution.