diff --git a/abra.sh b/abra.sh index 8a9ce80..21d74e6 100644 --- a/abra.sh +++ b/abra.sh @@ -1,5 +1,5 @@ export ENTRYPOINT_VERSION=v1 -export PG_BACKUP_VERSION=v1 +export PG_BACKUP_VERSION=v2 prepare_shutdown () { documentserver-prepare4shutdown.sh diff --git a/pg_backup.sh b/pg_backup.sh index f58d8ec..e83074d 100644 --- a/pg_backup.sh +++ b/pg_backup.sh @@ -11,17 +11,24 @@ function backup { function restore { cd /var/lib/postgresql/data/ + restore_config(){ + # Restore allowed connections + cat pg_hba.conf.bak > pg_hba.conf + su postgres -c 'pg_ctl reload' + } # Don't allow any other connections than local cp pg_hba.conf pg_hba.conf.bak echo "local all all trust" > pg_hba.conf su postgres -c 'pg_ctl reload' + trap restore_config EXIT INT TERM + # Recreate Database psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);" createdb -U ${POSTGRES_USER} ${POSTGRES_DB} psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE - # Restore allowed connections - cat pg_hba.conf.bak > pg_hba.conf - su postgres -c 'pg_ctl reload' + + trap - EXIT INT TERM + restore_config } $@