Like the title says, when restoring a Postgresql database onto a different server which happens to have a dfferent role owner, extra care is needed, otherwise similar error message below will come up:

pg_restore: from TOC entry 217; 1259 17163 TABLE users_collections webdev1
pg_restore: error: could not execute query: ERROR:  role "webdev1" does not exist
Command was: ALTER TABLE public.users_collections OWNER TO webdev1;

pg_restore: from TOC entry 218; 1259 17168 TABLE users_organizations webdev1
pg_restore: error: could not execute query: ERROR:  role "webdev1" does not exist
Command was: ALTER TABLE public.users_organizations OWNER TO webdev1;

pg_restore: warning: errors ignored on restore: 19

What happened was that there was no role named webdev1 on the Postgreseql server where the database restoring was performed. Instead, on my database server, I had a role named webdev2.

So the solution, which worked for me, was to drop the broken restored database, e.g. webdevdb , and re-run the pg_restore with --no-owner --role=webdev2 as the following:

$ sudo pg_restore -U postgres --no-owner --role=webdev2 -d webdevdb < webdev1.pgdump_2022-07-03

A quick explanation, --no-owner option prevents pg_restore trying to set the ownership of the objects to the original owner. Instead the objects will be owned by the user specified by --role option.

References: