PostgreSQL 9.1 pg_restore error regarding PLPGSQL PostgreSQL 9.1 pg_restore error regarding PLPGSQL postgresql postgresql

PostgreSQL 9.1 pg_restore error regarding PLPGSQL


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


I found the following workaround on this page:

http://archives.postgresql.org/pgsql-general/2011-10/msg00826.php

The idea is to use pg_restore -l to list the contents of the archive, grep out the extension that the user doesn't have permission to restore, and use pg_restore -L to use this elided list when restoring.

For example:

pg_restore -l ~/database.dump | grep -v "EXTENSION - plpgsql" > ~/restore_elementspg_restore -L ~/restore_elements ~/database.dump


If you're running Postgres 11's (or higher) version of pg_dump then you can take advantage of the new --no-comments flag.