Fix snapshot restoration script
kderme opened this issue · comments
Currently if an error occurs, eg out of disk which is common, the restoartion script continues and may end with missing data. It is therefore advised to use -v ON_ERROR_STOP=1
. However this has revealed a different error, which needs to be mitigated.
psql:db-sync-snapshot-schema-13.1-block-9767060-x86_64.sql:23: ERROR: schema "public" already exists
It is therefore advised to use -v ON_ERROR_STOP=1
-v variable=assignment
is not valid for pg_restore
(only psql
), so this won't work for our new snapshot format. Instead we'll need to pass --exit-on-error
when using pg_restore
The problem is that, when running pg_dump
, we specify --schema=public
, which generates a CREATE SCHEMA public
statement. There are a few ways to work around this:
- Run
pg_dump
without--schema=public
, or - Call
pg_restore
with--schema=public
, which skips theCREATE SCHEMA
statement
I'm going to go with option 2, because I think the results will be more predictable