Mario Weilguni <mweilguni@sime.com> writes:
> Here are the problems I've encountered:
> * pg_restore tries to create a table with ltree and ltree[] datatypes before the type itself is created, so it
fails.
Odd; what are the OIDs of the table and the datatypes?
> * several functions are already defined in template1, so "create database " will restore these functions. pg_restore
willtry to restore those functions as well
 
>   and fails. Maybe "create or replace function" can be used here?
No.  Use pg_restore per the documentation: make an empty database for it
to restore into (by cloning template0 instead of template1).
>   pg_restore: [archiver (db)] could not execute query: ERROR:  data type ltree[] has no default operator class for
accessmethod "gist"
 
>           You must specify an operator class for the index or define a
>           default operator class for the data type
Are you using recent sources?  As of two weeks or so ago, pg_dump should
know how to dump operator classes.
        regards, tom lane