feat(id.tjo.space): add restore backup script

This commit is contained in:
Tine 2025-03-10 21:57:37 +01:00
parent 0399f7a3c5
commit 2170a87e6b
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw

View file

@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail
echo "=== Reading Configuration"
set -a && source /etc/postgresql/postgresql.env && set +a
echo "== Stopping Authentik..."
systemctl stop authentik-server authentik-worker
echo "== Dropping and Recreating Database..."
podman exec systemd-postgresql dropdb --username="${POSTGRES_USER}" --force --if-exists "${POSTGRES_DB}"
podman exec systemd-postgresql createdb --username="${POSTGRES_USER}" "${POSTGRES_DB}"
echo "== Restoring Database..."
cat /dev/stdin | podman exec -i systemd-postgresql pg_restore \
--username="${POSTGRES_USER}" \
--dbname="${POSTGRES_DB}"
echo "== Starting Authentik..."
systemctl start authentik-server authentik-worker