Folks
After a bit of trial and error, I now have a pretty solid method for backing-up and restoring/replicating Postgres OpenACS databases.It avoids the problems of restoring functions and pgplsql and I've been using on several live sites for the last 6 months or more including automatically replicating the database to a developement site.
So I thought I'd share it in case its of use to anyone else.
Backup
Split the backup into two distinct files - one for the schema and one for the data. The following little script assumes an installation called service1 with a database called service1;
# Dump the data
/usr/local/pgsql/bin/pg_dump -U nsadmin --no-owner --disable-triggers --data-only \
-f /var/lib/aolserver/service1/database-backup/service1_data.dmp service1
# Dump the schema
/usr/local/pgsql/bin/pg_dump -U nsadmin --schema-only \
-f /var/lib/aolserver/service1/database-backup/service1_schema.dmp service1
Restore
Restoring with this method is now straightforward as the schema is applied before the data. So to replicate or restore the database saved above;
# Drop the existing DB
/usr/bin/dropdb service1
# Create a new one from template0 (avoids the pgpsql problems)
/usr/bin/createdb --template=template0 --encoding=UNICODE service1
# Restore the schema
/usr/bin/psql service1 < /var/lib/aolserver/service1/database-backup/service1_schema.dmp
# Restore the data
/usr/bin/psql service1 < /var/lib/aolserver/service1/database-backup/service1_data.dmp
Enjoy!
Steve