634028d508
Remove stacks no longer in use: ghost, ghost-me, changedetection, pdf (Stirling PDF), it (IT-Tools), finance (Actual Budget), bookstack, dozzle, beszel, memos, vikunja, onetimesecret and DEPRECATED-kasm. CrowdSec keeps only the engine (the Traefik bouncer is unchanged). Drop Grafana, Prometheus, crowdsec-postgres and metrics-export.sh, which only fed the local dashboard; CrowdSec itself uses SQLite. Also drop references to these services, THSCom, Scheduler and the SpinTools OpenProject from Kopia paths/dumps and ops-report endpoints, and replace the DEPRECATED- convention in the README with the removal procedure used here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.3 KiB
Bash
Executable File
84 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck disable=SC1091
|
|
source "$SCRIPT_DIR/kopia-common.sh"
|
|
|
|
require_cmd docker
|
|
ensure_runtime_dirs
|
|
|
|
DUMP_DIR="$BACKUP_STAGING_DIR/dumps"
|
|
RUN_DIR="$DUMP_DIR/latest"
|
|
mkdir -p "$RUN_DIR"
|
|
find "$RUN_DIR" -type f -name '*.dump' -delete
|
|
find "$RUN_DIR" -type f -name '*.sql.gz' -delete
|
|
|
|
container_running() {
|
|
[[ "$(docker inspect -f '{{.State.Running}}' "$1" 2>/dev/null || true)" == "true" ]]
|
|
}
|
|
|
|
container_env() {
|
|
local container="$1"
|
|
local key="$2"
|
|
docker exec "$container" sh -lc "printenv $key 2>/dev/null || true" | tr -d '\r'
|
|
}
|
|
|
|
dump_postgres() {
|
|
local container="$1"
|
|
local fallback_user="$2"
|
|
local fallback_db="$3"
|
|
|
|
if ! container_running "$container"; then
|
|
log "Skip PostgreSQL dump for $container: container not running"
|
|
return 0
|
|
fi
|
|
|
|
local user db out
|
|
user="$(container_env "$container" POSTGRES_USER)"
|
|
db="$(container_env "$container" POSTGRES_DB)"
|
|
user="${user:-$fallback_user}"
|
|
db="${db:-$fallback_db}"
|
|
out="$RUN_DIR/${container}.dump"
|
|
|
|
log "Dumping PostgreSQL $container/$db"
|
|
docker exec "$container" pg_dump -U "$user" -d "$db" -Fc > "$out"
|
|
}
|
|
|
|
dump_mariadb() {
|
|
local container="$1"
|
|
|
|
if ! container_running "$container"; then
|
|
log "Skip MariaDB dump for $container: container not running"
|
|
return 0
|
|
fi
|
|
|
|
local out
|
|
out="$RUN_DIR/${container}.sql.gz"
|
|
|
|
log "Dumping MariaDB $container"
|
|
docker exec "$container" sh -lc '
|
|
set -eu
|
|
db="${MYSQL_DATABASE:-nextcloud}"
|
|
user="${MYSQL_USER:-nextcloud}"
|
|
pass="${MYSQL_PASSWORD:-}"
|
|
if command -v mariadb-dump >/dev/null 2>&1; then
|
|
MYSQL_PWD="$pass" mariadb-dump --single-transaction --quick -u "$user" "$db"
|
|
else
|
|
MYSQL_PWD="$pass" mysqldump --single-transaction --quick -u "$user" "$db"
|
|
fi
|
|
' | gzip -c > "$out"
|
|
}
|
|
|
|
dump_postgres "paperless-db" "paperless" "paperless"
|
|
dump_postgres "gitea-postgres" "gitea" "gitea"
|
|
dump_postgres "n8n-pg" "n8n" "n8n"
|
|
dump_postgres "ths-authentik-postgres" "authentik" "authentik"
|
|
dump_postgres "guacamole-postgres" "guacamole" "guacamole"
|
|
dump_postgres "spintools-db" "postgres" "postgres"
|
|
dump_postgres "spintools-authentik-postgres" "authentik" "authentik"
|
|
dump_postgres "charge-card-lab-postgres" "charge_card_lab" "charge_card_lab"
|
|
dump_mariadb "nextcloud-db"
|
|
|
|
log "Database dumps written to $RUN_DIR"
|