From a4660ee3283e8b8c4c3dd90be6c474dcef3359bc Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Fri, 3 May 2024 18:44:10 +0200 Subject: [PATCH] fix(gitea): Convert from docker to k3s --- scripts/gitea/backup-database.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/gitea/backup-database.sh b/scripts/gitea/backup-database.sh index 08cd4c4..62bf904 100755 --- a/scripts/gitea/backup-database.sh +++ b/scripts/gitea/backup-database.sh @@ -43,9 +43,11 @@ else destination="${1}" fi +namespace="ix-gitea-2" + # Retrieve container names -base_container="$( docker ps --format '{{.Names}}' | grep -E 'gitea_gitea-[0-9a-z]{10}-[0-9a-z]{5}' )" -database_container="$( docker ps --format '{{.Names}}' | grep 'postgres_gitea-cnpg-main-1' )" +base_container="$( k3s kubectl get pods --namespace "${namespace}" | cut -f1 -d' ' | grep -E 'gitea-2-[0-9a-z]{10}-[0-9a-z]{5}' )" +database_container="$( k3s kubectl get pods --namespace "${namespace}" | cut -f1 -d' ' | grep 'gitea-2-cnpg-main-2' )" if ! [[ -n "${base_container}" && -n "${database_container}" ]]; then >&2 printf "Error: Not all containers could be found.\n" @@ -57,7 +59,7 @@ set -e # Enable maintenance mode # Flush queues -docker exec "${base_container}" gitea manager flush-queues +k3s kubectl exec "${base_container}" --namespace "${namespace}" -- gitea manager flush-queues # TODO Pause queues # Database backup @@ -68,7 +70,7 @@ host_database_backupfile="${destination}/${database_backupfile}" # Backup the database >&2 echo 'Backing up database' -docker exec --env-file "${env_file:=.env}" "${database_container}" pg_dump 'gitea' -cwv -h 'localhost' -U 'gitea' > "${host_database_backupfile}" +k3s kubectl exec "${database_container}" --namespace "${namespace}" -- env $(cat "${env_file:=.env}" | xargs) pg_dump 'gitea' -cwv -h 'localhost' -U 'gitea' > "${host_database_backupfile}" # Disable maintenance mode # TODO Continue queues