I use following command to dump some structures from server’ database to be able to create sample of data on my local hard drive.
pg_dump -h myserver.com -U product_user -s -f ./data/base.structure.postgresql.sql -F p -v -T public.* -T first_product.* -T second_product.* -T another_product.locales mydatabase
I need to exclude some schemas otherwise it would ended up on permissions or other errors. Even that I exclude schema public, it dumps all functions in that schema, like this:
REVOKE ALL ON FUNCTION gin_extract_trgm(text, internal) FROM PUBLIC;
psql:./data/base.structure.postgresql.sql:8482: ERROR: function gin_extract_trgm(text, internal) does not exist
I know this comes from the fulltext or similarity plugin in PostgreSQL, but I don’t use it and don’t need it on my machine, so I’d like to exclude these functions.
How could I do that?
pg_dump has a switch to exclude schemas:
I quote the manual about pg_dump:
With PostgreSQL 9.1 or later you have new options to move extensions into a separate schema – even pre-installed old-style modules. You can register old object with your (new-style) extension and then use the new tools. With
fulltextandsimilarityyou probably meanfuzzystrmatchandtsearch2. Example:Register existing old-style objects for the extension
fuzzystrmatch:Drop the extension:
Install it to another schema:
Of course, you cannot drop the extension, if objects from it are in use.
Also, if you install to another schema, you need to schema-qualify its functions in use or add the schema to the
search_path.