*: remove deprecated backup (#2129)
* *: remove backup Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix lint Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * website/docs: add docs Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * *: final cleanup Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ci: use correct pyproject when migrating from stable Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * website/docs: fix broken docs Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
30
lifecycle/ak
30
lifecycle/ak
@ -32,30 +32,6 @@ function check_if_root {
|
||||
chpst -u authentik:$GROUP env HOME=/authentik $1
|
||||
}
|
||||
|
||||
function prefixwith {
|
||||
local prefix="$1"
|
||||
shift
|
||||
"$@" > >(sed "s/^/$prefix: /") 2> >(sed "s/^/$prefix (err): /" >&2)
|
||||
}
|
||||
|
||||
function restore {
|
||||
PG_HOST=$(python -m authentik.lib.config postgresql.host 2> /dev/null)
|
||||
PG_NAME=$(python -m authentik.lib.config postgresql.name 2> /dev/null)
|
||||
PG_USER=$(python -m authentik.lib.config postgresql.user 2> /dev/null)
|
||||
PG_PORT=$(python -m authentik.lib.config postgresql.port 2> /dev/null)
|
||||
export PGPASSWORD=$(python -m authentik.lib.config postgresql.password 2> /dev/null)
|
||||
log "Ensuring no one can connect to the database"
|
||||
prefixwith "psql" psql -h"${PG_HOST}" -U"${PG_USER}" -c"UPDATE pg_database SET datallowconn = 'false' WHERE datname = '${PG_NAME}';" "postgres"
|
||||
prefixwith "psql" psql -h"${PG_HOST}" -U"${PG_USER}" -c"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${PG_NAME}';" "postgres"
|
||||
log "deleting and re-creating database"
|
||||
prefixwith "psql" dropdb -h"${PG_HOST}" -U"${PG_USER}" "${PG_NAME}" || trueacku
|
||||
prefixwith "psql" createdb -h"${PG_HOST}" -U"${PG_USER}" "${PG_NAME}"
|
||||
log "running initial migrations"
|
||||
prefixwith "migrate" python -m lifecycle.migrate 2> /dev/null
|
||||
log "restoring database"
|
||||
prefixwith "restore" python -m manage dbrestore -i ${@:2}
|
||||
}
|
||||
|
||||
MODE_FILE="/tmp/authentik-mode"
|
||||
|
||||
if [[ "$1" == "server" ]]; then
|
||||
@ -75,12 +51,6 @@ elif [[ "$1" == "worker" ]]; then
|
||||
elif [[ "$1" == "flower" ]]; then
|
||||
echo "flower" > $MODE_FILE
|
||||
celery -A authentik.root.celery flower
|
||||
elif [[ "$1" == "backup" ]]; then
|
||||
wait_for_db
|
||||
python -m manage dbbackup --clean
|
||||
elif [[ "$1" == "restore" ]]; then
|
||||
wait_for_db
|
||||
restore $@
|
||||
elif [[ "$1" == "bash" ]]; then
|
||||
/bin/bash
|
||||
elif [[ "$1" == "test" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user