0

I have a postgres 9.6. I am using pg_dumpall with -c --if-exists options.

When I restore from this backup file as the superuser I am getting errors current user cannot be dropped when it tries to drop the role. And after that I am getting role "mysuperuser" already exists when it tries to create the superuser role.

These two errors does not effect the success of the restore. However, I do not want to get irrelevant errors like these.

What I can do is to remove the two lines which are dropping and creating the aforementioned superuser role.

Is there a better way to do this? Because in order to achieve that I need to open a huge file and edit it.

Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67

1 Answers1

0

You might want to join one of the postgreql.org mailing list and see if this irritation has occurred for others. It's clearly not the ideal behaviour.

There is a simple work-around though. Create a new superuser (that doesn't exist in the backup) and use that user to do the restore.

Richard Huxton
  • 21,516
  • 3
  • 39
  • 51
  • 1
    this solution not works in my case. Postgres 10 returns this error: ERROR: cannot drop role postgres because it is required by the database system – Andrey Durow Nov 09 '18 at 14:49