I’m using an mac mini m1 and postgresl14 on it for a database migration.
For the migration a change of the owner is necessary.
To export the dump needed I log in on my mac, call sudo su
to become root and use the following cmd:
pg_dump -Fc --no-owner --encoding=UTF8 -h 127.0.0.1 -U postgres [[dbname]] -n [[schemaname]] > upload.bak
[[dbname]]
and [[schemaname]]
are placeholders here.
After that, I upload the upload.bak
file to my server instance of ubuntu24.
On that ubuntu server instance I try to import the file via
pg_restore -h 127.0.0.1 -U [[username]] -d [[dbname]] -n [[schemaname]]
The import begins to run, but it says:
pg_restore: error: could not execute query:
ERROR: role "[[old_role]]" does not exist
Command was: ALTER TABLE [[schemaname]].[[tablename]] OWNER TO [[old_role]];
Seems as if the "-O"
approx. "--no-owner"
param above is completely ignored, even though I called pg_dump
as root and postgres user.
How to instruct pg_dump
to not export the “update role” statements?
3