I am using Postgres for a django project and I am currently implementing a database backup/restore system that as simple as possible performs a pg_dump when the user clicks backup and then pg_restore when they click restore backup.
All seems fine and dandy until it actually tries to perform the pg_restore at which time it gives this error:
pg_restore: [archiver (db)] Error from TOC entry 3206; 0 0 COMMENT EXTENSION plpgsql pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of extension plpgsql Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
I've looked into what plpgsql is etc and I understand that, and regarding the error I tried manually setting the "owner of the extension" to the user who executes the script and owns the database itself but that changed nothing, its really annoying since its erroring on an attempt to set a comment of all things
This is all created automatically by pg_dump so the comment line cant be removed and there are no flags to disable comments (that I'm aware off), so I'm truly stuck as to how to solve this issue.
Description. pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved.
The message means that the command "COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'" had the error. In most cases, this message can be ignored. During the restore, it tries restoring this comment. However, the restore user was not owner of the extension plpgsql, causing the error.
pg_dump, pg_dump_all, pg_restore are all located in the bin folder of the PostgreSQL install and PgAdmin III install.
It seems like pg_restore tries to restore some extra data which you don't own. Try to add -n public
option to your pg_restore command line. It will tell pg_restore restore only contents of public schema. Your command line should looks like
pg_restore -U username -c -n public -d database_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With