feat: add Pi monitoring stack with deployment scripts and architecture documentation

This commit is contained in:
S
2026-03-02 21:12:24 -05:00
parent ca4f4924b6
commit 780748083f
16 changed files with 1106 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=./lib.sh
source "$SCRIPT_DIR/lib.sh"
ARCHIVE=""
AUTO_YES=false
usage() {
cat <<USAGE
Usage: $(basename "$0") --archive=/path/to/pi-monitoring-*.tar.gz [options]
Restore monitoring stack data/config from a backup archive created by backup_stack.sh.
Options:
--archive=PATH Backup archive to restore (required)
--yes, -y Skip confirmation prompt
--help, -h Show help
USAGE
}
for arg in "$@"; do
case "$arg" in
--archive=*) ARCHIVE="${arg#*=}" ;;
--yes|-y) AUTO_YES=true ;;
--help|-h) usage; exit 0 ;;
*) log_error "Unknown argument: $arg"; usage; exit 1 ;;
esac
done
require_cmd tar
if [[ -z "$ARCHIVE" ]]; then
log_error "--archive is required"
usage
exit 1
fi
if [[ ! -f "$ARCHIVE" ]]; then
log_error "Archive not found: $ARCHIVE"
exit 1
fi
if ! confirm_action "Restore from $ARCHIVE? Existing stack data may be overwritten." "$AUTO_YES"; then
log_info "Cancelled"
exit 0
fi
log_info "Stopping compose services before restore (best effort)..."
if [[ -f "$SCRIPT_DIR/stack.env" ]]; then
load_stack_env "$SCRIPT_DIR/stack.env"
docker compose \
--project-name "$COMPOSE_PROJECT_NAME" \
--env-file "$SCRIPT_DIR/stack.env" \
-f "$(compose_file)" \
down || true
fi
log_info "Extracting backup archive to / ..."
sudo tar -xzf "$ARCHIVE" -C /
log_success "Restore complete"
log_info "Run deploy_stack.sh to bring services back up"