fix(gitea): Convert from docker to k3s

This commit is contained in:
Tibo De Peuter 2024-05-03 18:44:10 +02:00
parent a89fac7e25
commit a4660ee328
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2

View file

@ -43,9 +43,11 @@ else
destination="${1}" destination="${1}"
fi fi
namespace="ix-gitea-2"
# Retrieve container names # Retrieve container names
base_container="$( docker ps --format '{{.Names}}' | grep -E 'gitea_gitea-[0-9a-z]{10}-[0-9a-z]{5}' )" 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="$( docker ps --format '{{.Names}}' | grep 'postgres_gitea-cnpg-main-1' )" 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 if ! [[ -n "${base_container}" && -n "${database_container}" ]]; then
>&2 printf "Error: Not all containers could be found.\n" >&2 printf "Error: Not all containers could be found.\n"
@ -57,7 +59,7 @@ set -e
# Enable maintenance mode # Enable maintenance mode
# Flush queues # Flush queues
docker exec "${base_container}" gitea manager flush-queues k3s kubectl exec "${base_container}" --namespace "${namespace}" -- gitea manager flush-queues
# TODO Pause queues # TODO Pause queues
# Database backup # Database backup
@ -68,7 +70,7 @@ host_database_backupfile="${destination}/${database_backupfile}"
# Backup the database # Backup the database
>&2 echo 'Backing up 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 # Disable maintenance mode
# TODO Continue queues # TODO Continue queues