#!/usr/bin/env bash set -euo pipefail # === METADATA === SCRIPT_NAME="$(basename "$0")" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SKILL_ROOT="$(dirname "$SCRIPT_DIR")" # === CONFIGURATION === : "${OUTPUT_DIR:=$SKILL_ROOT/outputs}" # === FUNCTIONS === log_info() { echo "[INFO] $(date -Iseconds) $*"; } log_warn() { echo "[WARN] $(date -Iseconds) $*" >&2; } log_error() { echo "[ERROR] $(date -Iseconds) $*" >&2; } die() { log_error "$@"; exit 1; } check_file() { local path="$1" local name="$2" if [[ -f "$path" ]]; then local size size=$(stat -c%s "$path") log_info "[OK] $name ($size bytes)" return 0 else log_warn "[MISSING] $name" return 1 fi } main() { local last_run_file="$OUTPUT_DIR/last_run_dir.txt" [[ -f "$last_run_file" ]] || die "No last run pointer. Run 11_backup_apply.sh first." local run_dir run_dir="$(cat "$last_run_file")" log_info "Verifying backup artifacts..." log_info "Run directory: $run_dir" echo "" local missing=0 log_info "=== Core Artifacts ===" check_file "$run_dir/archive.tar.gz" "archive.tar.gz" || ((missing++)) check_file "$run_dir/archive.tar.gz.age" "archive.tar.gz.age" || ((missing++)) check_file "$run_dir/manifest.json" "manifest.json" || ((missing++)) echo "" log_info "=== Proof Artifacts ===" check_file "$run_dir/ROOT.txt" "ROOT.txt" || ((missing++)) check_file "$run_dir/PROOF.json" "PROOF.json" || ((missing++)) echo "" log_info "=== Metadata ===" check_file "$run_dir/excludes.txt" "excludes.txt" || true echo "" if [[ $missing -gt 0 ]]; then die "Verification failed: $missing missing artifacts." fi log_info "=== ROOT Value ===" local root root=$(cat "$run_dir/ROOT.txt") log_info "ROOT: $root" echo "" log_info "Verification complete. All artifacts present." log_info "Next: ./scripts/50_restore_drill.sh (MANDATORY)" } [[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@"