Initial commit: k8s cluster manifests and scripts

This commit is contained in:
2026-04-01 15:34:02 +08:00
commit 2f04fa4473
49 changed files with 4109 additions and 0 deletions

20
apps/postgres/backup.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# 用途:備份 Postgres 到本機(使用 pg_dumpall
set -euo pipefail
BACKUP_DIR="$(cd "$(dirname "$0")" && pwd)/backups"
mkdir -p "$BACKUP_DIR"
POD=$(kubectl get pod -l app=postgres -o jsonpath='{.items[0].metadata.name}')
TS=$(date +%Y%m%d_%H%M%S)
OUT="$BACKUP_DIR/postgres-backup-$TS.sql"
echo "使用 Pod$POD"
echo "開始備份..."
kubectl exec "$POD" -- sh -c 'pg_dumpall -U "$POSTGRES_USER"' > "$OUT"
echo "備份完成:"
echo "$OUT"