0

I backed up a server with

pg_dumpall.exe --file "backup.sql" --host "db" --port "5432" --username "user" --no-password --database "postgres" --verbose --clean

but when I tried to restore it on a new machine, I'm getting

postgres@home-lab-db-15:/home/ubuntu$ psql -f home-lab-db.sql postgres  -v ON_ERROR_STOP=1
SET
SET
SET
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
CREATE ROLE
ALTER ROLE
psql:home-lab-db.sql:24: ERROR:  role "postgres" already exists

I tried to drop the cluster and recreate it, but same error. I could not drop the postgres role or database cannot drop role postgres because it is required by the database system

The docs say

if you are loading into an empty cluster then postgres should usually be used

so I'm confused at how to restore the backup.

1 Answer 1

0

That error is expected and should be ignored. You cannot restore a pg_dumpall with ON_ERROR_STOP set.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.