#!/usr/bin/env bash set -euo pipefail OPS_REPO_PATH="${OPS_REPO_PATH:-/srv/ops}" OUT_BASE="${OUT_BASE:-/srv/backups/ops}" TS="$(date +%F_%H%M%S)" OUT_DIR="$OUT_BASE/$TS" LATEST_DIR="$OUT_BASE/latest" if [[ ! -d "$OPS_REPO_PATH/.git" ]]; then echo "Missing git repo at $OPS_REPO_PATH" exit 1 fi mkdir -p "$OUT_DIR" git -C "$OPS_REPO_PATH" bundle create "$OUT_DIR/ops.bundle" --all mkdir -p "$LATEST_DIR" cp "$OUT_DIR/ops.bundle" "$LATEST_DIR/ops.bundle" echo "Wrote bundle: $OUT_DIR/ops.bundle" echo "Updated latest: $LATEST_DIR/ops.bundle"