简体   繁体   中英

pg_dump and pg_restore not working as expected

I am new to Postgres, I have a DB host(HOST1) which has multiple DB instances, and I have now provisioned another host (HOST2).

I created a dump file using pg_dump on HOST1 and ran a pg_restore on HOST2. I see that the restore is not able to restore the DB Roles with the required GRANTS in the new host HOST2.

Do I need to use pgdumpall to capture all the DB roles with the relevant GRANTS/privileges from HOST1 and then restore into HOST2?

Specifically you need to use pg_dumpall -g . That will capture just the global data(roles,tablespaces, etc). It will not capture the GRANT information, that is what is in the pg_dump output. The issue you ran into is that the pg_restore was trying to GRANT privileges for ROLEs that did not exist in the database cluster global information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM