Include AppFactory platform data in backups

This commit is contained in:
2026-06-08 09:51:42 +02:00
parent 817e8ff862
commit e3fc259c1b
+43 -11
View File
@@ -2,26 +2,58 @@
set -euo pipefail set -euo pipefail
CONFIG_FILE="/opt/appfactory/config/appfactory.env" CONFIG_FILE="/opt/appfactory/config/appfactory.env"
source "$CONFIG_FILE"
if [ -f "$CONFIG_FILE" ]; then
set -a
# shellcheck disable=SC1090
source "$CONFIG_FILE"
set +a
fi
APPFACTORY_DIR="${APPFACTORY_DIR:-/opt/appfactory}"
WORKSPACE_DIR="${WORKSPACE_DIR:-$APPFACTORY_DIR/workspace}"
BACKUP_DIR="${BACKUP_DIR:-$APPFACTORY_DIR/backups}"
TIMESTAMP="$(date +%Y%m%d-%H%M%S)" TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
BACKUP_FILE="$BACKUP_DIR/appfactory-backup-$TIMESTAMP.tar.gz" BACKUP_FILE="$BACKUP_DIR/appfactory-backup-$TIMESTAMP.tar.gz"
MANIFEST_FILE="$(mktemp)"
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
add_path() {
local path="$1"
if [ -e "$path" ]; then
echo "$path" >> "$MANIFEST_FILE"
else
echo "WARN: missing path skipped: $path" >&2
fi
}
add_path "$APPFACTORY_DIR/apps"
add_path "$APPFACTORY_DIR/config"
# AppFactory portal/platform DB and internal data.
add_path "$APPFACTORY_DIR/data/appfactory"
# Core service persistent data.
add_path "$APPFACTORY_DIR/data/gitea"
add_path "$APPFACTORY_DIR/data/registry"
add_path "$APPFACTORY_DIR/data/caddy"
add_path "$APPFACTORY_DIR/data/caddy-config"
add_path "$APPFACTORY_DIR/deploy"
add_path "$APPFACTORY_DIR/gateway"
add_path "$APPFACTORY_DIR/templates"
add_path "$APPFACTORY_DIR/services"
add_path "$WORKSPACE_DIR"
echo "Creating backup:" echo "Creating backup:"
echo "$BACKUP_FILE" echo "$BACKUP_FILE"
tar -czf "$BACKUP_FILE" \ tar -czf "$BACKUP_FILE" --files-from "$MANIFEST_FILE"
"$APPFACTORY_DIR/apps" \
"$APPFACTORY_DIR/config" \ rm -f "$MANIFEST_FILE"
"$APPFACTORY_DIR/data/gitea" \
"$APPFACTORY_DIR/data/registry" \
"$APPFACTORY_DIR/deploy" \
"$APPFACTORY_DIR/gateway" \
"$APPFACTORY_DIR/templates" \
"$APPFACTORY_DIR/services" \
"$WORKSPACE_DIR"
echo "" echo ""
echo "DONE" echo "DONE"