#!/usr/bin/env bash
# backend/scripts/restore.sh <backup.db.gz> — 복구(재기동 필요)
set -euo pipefail
SRC="${1:?usage: restore.sh /backups/ari-<ts>.db.gz}"
DB="${DATABASE_URL:-sqlite:////data/ari.db}"
DB_PATH="${DB#sqlite:///}"
TMP="$(mktemp)"
gunzip -c "$SRC" > "$TMP"
mv "$TMP" "$DB_PATH"
echo "restored $SRC → $DB_PATH (backend/worker 재기동 필요)"
