#!/bin/sh # Dump Authentik's database and keep it with the settings, two weeks of them. # From https://exe.dev/deploy/authentik. Run nightly by authentik-backup.timer. set -eu umask 077 cd "$(dirname "$0")" mkdir -p backups work=$(mktemp -d) trap 'rm -rf "$work"' EXIT docker compose exec -T postgresql pg_dump -U authentik -d authentik -Fc > "$work/authentik.dump" docker compose exec -T postgresql pg_restore --list < "$work/authentik.dump" | grep -q 'TABLE DATA public authentik_core_user ' cp .env compose.yaml nginx.conf ak backup.sh "$work"/ cp -r blueprints custom-templates "$work"/ tar -cf "$work/data.tar" data out="backups/authentik-$(date +%Y%m%d-%H%M%S).tar.gz" tar -czf "$out.tmp" -C "$work" . mv "$out.tmp" "$out" find backups -name 'authentik-*.tar.gz' -mtime +14 -delete echo "$out"