if [ "$1" == "pre-backup" ]; then # Remove any existing db dump and then create a new one rm -rf /var/lib/postgresql/data/postgres-backup PGPASSWORD=$(cat ${POSTGRES_PASSWORD_FILE}) pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} --format=directory -f /var/lib/postgresql/data/postgres-backup exit fi if [ "$1" == "post-backup" ]; then rm -rf /var/lib/postgresql/data/postgres-backup exit fi if [ "$1" == "pre-restore" ]; then exit fi if [ "$1" == "post-restore" ]; then pg_restore -U $POSTGRES_USER -d $POSTGRES_DB -c /var/lib/postgresql/data/postgres-backup fi