feat(id.tjo.space): add restore backup script
This commit is contained in:
parent
0399f7a3c5
commit
2170a87e6b
1 changed files with 20 additions and 0 deletions
20
id.tjo.space/root/usr/local/bin/postgresql-backup-restore.sh
Executable file
20
id.tjo.space/root/usr/local/bin/postgresql-backup-restore.sh
Executable 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
|
Loading…
Reference in a new issue