platform-deployments/provisioning/setup-backup-infrastructure.sh
2026-01-13 06:31:01 -08:00

80 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Backup Infrastructure Setup - Bash Wrapper
#
# Usage:
# ./setup-backup-infrastructure.sh [options]
#
# Options:
# --config <path> Config file path
# --phase <name> Phase: server|client|vault|backup|all
# --dry-run Dry run mode
# --host <name> Target specific host
# --help Show help
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TS_SCRIPT="$SCRIPT_DIR/setup-backup-infrastructure.ts"
# Check if tsx is available
if ! command -v tsx &> /dev/null; then
echo "Error: tsx not found"
echo "Install with: pnpm add -g tsx"
exit 1
fi
# Check if TypeScript script exists
if [ ! -f "$TS_SCRIPT" ]; then
echo "Error: $TS_SCRIPT not found"
exit 1
fi
# Show help
if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
cat << 'EOF'
Backup Infrastructure Setup
Automates the complete backup infrastructure setup using declarative config.
Usage:
./setup-backup-infrastructure.sh [options]
Options:
--config <path> Path to config file (default: backup-infrastructure.config.yaml)
--phase <name> Run specific phase: server, client, vault, backup, or all (default: all)
--dry-run Show what would be done without executing
--host <name> Run only for specific host (apricot|macbook)
--help Show this help
Examples:
# Full setup (all phases)
./setup-backup-infrastructure.sh
# Dry run (preview)
./setup-backup-infrastructure.sh --dry-run
# Deploy server only
./setup-backup-infrastructure.sh --phase server
# Setup apricot only
./setup-backup-infrastructure.sh --host apricot
# Setup macbook encrypted backups
./setup-backup-infrastructure.sh --phase backup --host macbook
Phases:
server - Deploy restic REST server on black
client - Configure restic clients on workstations
vault - Setup vault symlinks and Keychain
backup - Configure encrypted backups on macbook
all - Run all phases (default)
See README-backup-setup.md for detailed documentation.
EOF
exit 0
fi
# Run TypeScript script with all args passed through
echo "Running setup..."
exec tsx "$TS_SCRIPT" "$@"