Publish deployment and backup scripts

This commit is contained in:
2026-04-11 00:21:08 +02:00
parent 86204e0836
commit 9de9acec48
27 changed files with 3709 additions and 206 deletions

120
backup-all.sh Executable file
View File

@@ -0,0 +1,120 @@
#!/usr/bin/env bash
# ==============================================================================
# Full Server Backup Script
# ==============================================================================
# Discovers deployed services by scanning /opt/*/docker-compose.yml and
# local service units, runs the appropriate backup script for each, then
# creates a combined full-server archive.
#
# Usage: backup-all.sh
# backup-all.sh --cold
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/common.sh"
parse_args "$@"
BACKUP_DIR="/opt/backup"
STAMP="$(date +%Y%m%d-%H%M%S)"
COLD_FLAG=""
[[ "$ARG_COLD" == "1" ]] && COLD_FLAG="--cold"
mkdir -p "$BACKUP_DIR"
echo ""
echo -e "${CYAN}══════════════════════════════════════════════${NC}"
echo -e "${CYAN} Full Server Backup${NC}"
echo -e "${CYAN}══════════════════════════════════════════════${NC}"
if [[ -n "$COLD_FLAG" ]]; then
echo -e " Mode: ${YELLOW}Cold (services will be stopped)${NC}"
else
echo -e " Mode: Hot (services stay running)"
fi
echo -e "${CYAN}══════════════════════════════════════════════${NC}"
echo ""
failed=0
# --- Traefik ---
if [[ -d /opt/traefik ]]; then
info "Backing up traefik..."
"${SCRIPT_DIR}/backup-traefik.sh" $COLD_FLAG || { warn "Traefik backup failed."; (( failed++ )); }
fi
# --- Mattermost ---
if [[ -f /opt/mattermost/docker-compose.yml ]]; then
info "Backing up mattermost..."
"${SCRIPT_DIR}/backup-mattermost.sh" $COLD_FLAG || { warn "Mattermost backup failed."; (( failed++ )); }
fi
# --- Gitea ---
if [[ -f /opt/gitea/docker-compose.yml ]]; then
info "Backing up gitea..."
"${SCRIPT_DIR}/backup-gitea.sh" $COLD_FLAG || { warn "Gitea backup failed."; (( failed++ )); }
fi
# --- Hermes ---
if [[ -f /opt/hermes/docker-compose.yml ]] || [[ -f /etc/systemd/system/hermes.service ]]; then
info "Backing up hermes..."
"${SCRIPT_DIR}/backup-hermes.sh" $COLD_FLAG || { warn "Hermes backup failed."; (( failed++ )); }
fi
# --- Paperclip ---
if [[ -d /opt/paperclip ]]; then
info "Backing up paperclip..."
"${SCRIPT_DIR}/backup-paperclip.sh" $COLD_FLAG || { warn "Paperclip backup failed."; (( failed++ )); }
fi
# --- OpenClaw ---
if [[ -d /opt/openclaw ]]; then
info "Backing up openclaw..."
"${SCRIPT_DIR}/backup-openclaw.sh" $COLD_FLAG || { warn "OpenClaw backup failed."; (( failed++ )); }
fi
# --- Open WebUI ---
if [[ -f /opt/open-webui/docker-compose.yml ]]; then
info "Backing up open-webui..."
"${SCRIPT_DIR}/backup-open-webui.sh" $COLD_FLAG || { warn "Open WebUI backup failed."; (( failed++ )); }
fi
# --- AgenticSeek ---
if [[ -f /opt/agenticseek/docker-compose.yml ]]; then
info "Backing up agenticseek..."
"${SCRIPT_DIR}/backup-agenticseek.sh" $COLD_FLAG || { warn "AgenticSeek backup failed."; (( failed++ )); }
fi
# --- Web instances (discover by /opt/*/docker-compose.yml with web- container) ---
for dir in /opt/*/; do
dir_name="$(basename "$dir")"
compose="${dir}docker-compose.yml"
if [[ -f "$compose" ]] && grep -q "web-${dir_name}" "$compose" 2>/dev/null; then
info "Backing up web instance: ${dir_name}..."
"${SCRIPT_DIR}/backup-web.sh" --dir "$dir_name" $COLD_FLAG || { warn "Web (${dir_name}) backup failed."; (( failed++ )); }
fi
done
# --- Combined full-server archive ---
FULL_BACKUP="${BACKUP_DIR}/backup-all-${STAMP}.tar.gz"
info "Creating combined full-server archive..."
tar czf "$FULL_BACKUP" -C / opt/ 2>/dev/null || warn "Full archive creation failed."
# --- Rotate full archives (keep last 3) ---
# shellcheck disable=SC2012
ls -t "${BACKUP_DIR}/backup-all-"*.tar.gz 2>/dev/null | tail -n +4 | xargs -r rm --
# --- Summary ---
echo ""
echo -e "${GREEN}══════════════════════════════════════════════${NC}"
echo -e "${GREEN} Backup complete${NC}"
echo -e "${GREEN}══════════════════════════════════════════════${NC}"
if [[ -f "$FULL_BACKUP" ]]; then
echo -e " Full: ${FULL_BACKUP} ($(du -h "$FULL_BACKUP" | cut -f1))"
fi
echo -e " Dir: ${BACKUP_DIR}/"
if (( failed > 0 )); then
echo -e " ${YELLOW}Warnings: ${failed} backup(s) had issues${NC}"
fi
echo -e "${GREEN}══════════════════════════════════════════════${NC}"
echo ""