59 lines
1.3 KiB
Bash
Executable File
59 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
CONFIG_FILE="/opt/appfactory/config/appfactory.env"
|
|
|
|
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)"
|
|
BACKUP_FILE="$BACKUP_DIR/appfactory-backup-$TIMESTAMP.tar.gz"
|
|
MANIFEST_FILE="$(mktemp)"
|
|
|
|
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"
|
|
|
|
add_path "$APPFACTORY_DIR/data/appfactory"
|
|
add_path "$APPFACTORY_DIR/data/apps"
|
|
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 "$BACKUP_FILE"
|
|
|
|
tar -czf "$BACKUP_FILE" --files-from "$MANIFEST_FILE"
|
|
|
|
rm -f "$MANIFEST_FILE"
|
|
|
|
echo ""
|
|
echo "DONE"
|
|
echo "$BACKUP_FILE"
|