0

I have put in a lot of effort trying to understand the process of pg_dump and pg_restore but there are a few key things that i still dont understand. My goal is to copy a schema from a production database with many roles to my local replication where i only need to use a postgres admin user.

I dump myschema with this syntax

pg_dump -h "pgprod" -p "5432" -d prod_db -U "myuser" -Fc -C --verbose --schema "myschema" -f .\test.backup 

Restore

pg_restore -U postgres -h localhost -p 5432 -d localdb -C -v --no-acl --role=postgres test.backup 

But I cannot work out how to ignore any form of roles that was exisiting in the prod_db. I also tried the flag –no-owner with the same result. I am completely stuck at this step, since i dont understand why this is happening. Running postgres 16

pg_restore: error: could not execute query: ERROR: role "user1" does not exist Command was: ALTER TABLE public."mytable" OWNER TO user1; 

1 Answer 1

1

I don't think you should specify --role.

Just add --no-acl and --no-owner to the pg_restore command line, and all objects will belong to the user who connects with pg_restore.

1
  • Thank you, i think that solved the issue. Now I am having other problems. But your suggestions seem to be correct. Commented Jan 16 at 14:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.