#!/usr/bin/env bash
# Use the unofficial bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail; export FS=$'\n\t'

echo "Started Keycloak database backup to $1/keycloak.sql ..."

${CMD} exec postgres /bin/bash -lc 'PGPASSWORD=${POSTGRESQL_PASSWORD} /usr/bin/pg_dump -U keycloak keycloak' > $1/keycloak.sql

echo "Finished Keycloak database backup."
