Documentation - Three levels: DOCS/General (overview, configuration), DOCS/Deployment (choose a method, first steps), details per method in Containers/ and System_Services/; new root README and DOCS/README map. - Remove superseded pages (Deployment.md, Deployment_Docker/Native.md, Index.md); split the two scenario guides by section. - Isolate the Timeweb/Hysteria2 records in DEPLOYMENTS/timeweb-hysteria2/ (not linked from DOCS, listed in .graphifyignore). - Add DOCS/code_review/ with a time-stamped analysis of the code base. Gatherer (BUG-02, BUG-03) - Session key (CN, address, connected_since_ts), baseline from the active_sessions snapshot, grace period for sessions missing from the status. - Status file integrity (TITLE/TIME/END) and freshness; a torn read skips the tick. - Cache applied after commit; main loop survives exceptions, backs off, and stops cleanly on SIGTERM/SIGINT; new client rows start with the first frame's totals; five tests. JWT signing key (SEC-01) - No built-in default: Core and Profiler refuse to start with a missing, placeholder or short (< 32) key; shipped config.ini has an empty value. - Same rule in install.sh, update.sh (issues a new key when missing or weak), docker lib/entrypoint; five tests, conftest.py for the test key. Each change has a plan and a summary under DOCS/Changes/. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
81 lines
3.1 KiB
Bash
Executable File
81 lines
3.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Restore the five data volumes from a backup directory (made by backup.sh or update.sh).
|
|
#
|
|
# deploy/docker/restore.sh BACKUP_DIR [--variant a|b] [--project NAME] [--yes] [--start]
|
|
#
|
|
# BACKUP_DIR e.g. backups/20261005T101500Z
|
|
# --start start the stack after the restore (default: only print the command)
|
|
#
|
|
# The application containers are stopped (after confirmation); the CURRENT content of the volumes is
|
|
# first saved to backups/<timestamp>-pre-restore (OVPMON_NO_SAFETY_BACKUP=1 skips it), then each volume
|
|
# is emptied and refilled from its archive. Volumes are never removed. .env is not touched: the copy
|
|
# in the backup is only reported. To also go back to the previous images use: update.sh --rollback
|
|
# See DOCS/Deployment/Containers/README.md
|
|
set -eu
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
|
. "$SCRIPT_DIR/lib.sh"
|
|
|
|
usage() {
|
|
sed -n '2,13p' "$0" | sed 's/^# \{0,1\}//'
|
|
}
|
|
|
|
ARG_VARIANT=""
|
|
ARG_PROJECT=""
|
|
ASSUME_YES=0
|
|
START=0
|
|
SRC=""
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--variant) [ $# -ge 2 ] || die "--variant needs a value"; ARG_VARIANT="$2"; shift 2 ;;
|
|
--project) [ $# -ge 2 ] || die "--project needs a value"; ARG_PROJECT="$2"; shift 2 ;;
|
|
--yes|-y) ASSUME_YES=1; shift ;;
|
|
--start) START=1; shift ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
-*) usage >&2; die "unknown option: $1" ;;
|
|
*) [ -z "$SRC" ] || die "only one backup directory can be given"; SRC="$1"; shift ;;
|
|
esac
|
|
done
|
|
[ -n "$SRC" ] || { usage >&2; die "BACKUP_DIR is required"; }
|
|
[ -d "$SRC" ] || die "not a directory: $SRC"
|
|
SRC=$(cd "$SRC" && pwd)
|
|
|
|
trap release_lock EXIT
|
|
trap 'exit 130' INT
|
|
trap 'exit 143' TERM
|
|
need_docker
|
|
resolve_stack
|
|
acquire_lock
|
|
|
|
# The archives belong to the volumes of one project
|
|
BK_PROJECT=$(sed -n 's/^project=//p' "$SRC/MANIFEST" 2>/dev/null | tail -n 1 || true)
|
|
if [ -n "$BK_PROJECT" ] && [ "$BK_PROJECT" != "$PROJECT" ]; then
|
|
die "the backup belongs to project '$BK_PROJECT', this stack uses '$PROJECT' (use --project $BK_PROJECT)"
|
|
fi
|
|
log "backup: $SRC"
|
|
[ -f "$SRC/MANIFEST" ] && sed 's/^/ /' "$SRC/MANIFEST"
|
|
[ -f "$SRC/COMPLETE" ] || warn "the backup is not marked COMPLETE (an interrupted backup?)"
|
|
log "verifying the backup"
|
|
verify_backup "$SRC" || die "the backup is damaged or incomplete: nothing was changed"
|
|
if [ -f "$SRC/.env" ] && [ -f "$ENV_FILE" ] && ! cmp -s "$SRC/.env" "$ENV_FILE"; then
|
|
warn ".env differs from the copy in the backup ($SRC/.env); it is NOT restored. A different JWT_SECRET logs everybody out."
|
|
fi
|
|
|
|
log "the content of the volumes of project $PROJECT will be REPLACED by this backup (the current content is saved first)"
|
|
confirm "Stop the stack and restore?" || die "aborted by the user"
|
|
|
|
if stack_running; then
|
|
log "stopping the application containers"
|
|
dc stop
|
|
fi
|
|
restore_volumes "$SRC" 1 || die "the restore failed (see above). The backup is intact: $SRC"
|
|
log "restore complete"
|
|
|
|
if [ "$START" = 1 ]; then
|
|
dc up -d
|
|
wait_healthy || die "the stack did not become healthy after the restore"
|
|
else
|
|
log "start the stack when ready: $DC_BIN -p $PROJECT -f $(basename "$COMPOSE_FILE") up -d"
|
|
fi
|