Docker Compose stack (n8n, PostgreSQL 16, Redis 7, 1 worker) with: - nginx local proxy on port 8088, YunoHost TLS termination config - helper scripts: backup/restore/import/export/update - .env.example, README with architecture, ops commands, to-do list Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
Bash
Executable file
50 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT="$(dirname "$SCRIPT_DIR")"
|
|
COMPOSE="$ROOT/compose/docker-compose.yml"
|
|
ENV="$ROOT/.env"
|
|
|
|
if [ -z "${1:-}" ]; then
|
|
echo "Verwendung: $0 <backup-verzeichnis>"
|
|
echo "Verfügbare Backups:"
|
|
ls -lht "$ROOT/backups/"
|
|
exit 1
|
|
fi
|
|
|
|
BACKUP="$1"
|
|
if [ ! -d "$BACKUP" ]; then
|
|
echo "Fehler: Verzeichnis '$BACKUP' nicht gefunden."
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck source=/dev/null
|
|
source "$ENV"
|
|
|
|
echo "[restore] Stelle wieder her aus: $BACKUP"
|
|
echo "[restore] Stack wird gestoppt..."
|
|
docker compose -f "$COMPOSE" down
|
|
|
|
# n8n data
|
|
echo "[restore] n8n Daten..."
|
|
rm -rf "$ROOT/data/n8n"
|
|
mkdir -p "$ROOT/data/n8n"
|
|
tar -xzf "$BACKUP/n8n-data.tar.gz" -C "$ROOT/data"
|
|
|
|
# Postgres
|
|
echo "[restore] Datenbank wird gestartet..."
|
|
docker compose -f "$COMPOSE" up -d postgres
|
|
echo "[restore] Warte auf PostgreSQL..."
|
|
sleep 10
|
|
|
|
echo "[restore] Datenbank-Restore..."
|
|
docker compose -f "$COMPOSE" exec -T postgres \
|
|
psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
|
|
< "$BACKUP/postgres.sql"
|
|
|
|
echo "[restore] Stack wird neu gestartet..."
|
|
docker compose -f "$COMPOSE" up -d
|
|
|
|
echo "[restore] Fertig. Stack-Status:"
|
|
docker compose -f "$COMPOSE" ps
|