mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 21:02:12 +03:00
A base tinha base-red sistêmica herdada de PRs de outras sessões, bloqueando TODOS os PRs do ciclo (o TIA roda a suíte full em fail-safe p/ diffs hub). 4 Fast Quality Gates: - test-discovery (#4877): live-server-allowlist.test.ts em tests/unit/server/ (não-coletado) + vitest → nunca rodava. Convertido p/ node:test em tests/unit/security/. - any-budget:t11 (#4664): 3 explicit-any em tokenRefresh.ts tipados (sem crescer file-size). - docs-symbols (#4868): rotas inexistentes → /api/system/version e PUT /api/providers/{id} {isActive:false}. - docs-all fabricated-claim (#4868 + #4718): 5 bin/*.sh reais criados (rollback, snapshot-data, restore-data, restore-policies, cold-start-bench) + _ops-common.sh (snapshot VACUUM INTO, guards de confirmação/TTY, testes de contrato); NODE_EXTRA_CA_CERTS (env de runtime Node) na allowlist do checker. 7 testes unit base-red (de features alheias à quota): - oauth-providers-config (#4664): teste alinhado ao provider codebuddy-cn do registry. - antigravity-model-aliases (#4636): maxOutputTokens esperado 32769→16384 (cap intencional). - provider-request-capture #4091 (#4861): exemplo do teste trocado de mcp__ (que #4861 isenta de cloak por causa dos 400s de assimetria de histórico) para um tool de terceiro cloakável — preserva o invariante de #4091 SEM reverter #4861. - combo-error-response: convertido de vitest p/ node:test (era coletado pelo glob node:test e crashava); api/** e server/** removidos do vitest.config (config morta). Build MDX (dast-smoke, #4679): - docs/ops/RELEASE_GREEN.md não tinha frontmatter `title` → fumadocs-mdx rejeitava no webpack compile ("invalid frontmatter: title expected string"), quebrando o next build (e o deploy). Frontmatter title adicionado (único doc do collection sem ele). 17/17 Fast Quality Gates + suíte unit completa (17737 testes, 0 fail) + vitest verdes localmente. Co-authored-by: Diego Rodrigues de Sa e Souza <souzamiriamrodrigues790@gmail.com>
65 lines
2.4 KiB
Bash
Executable File
65 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# bin/restore-data.sh — restore the OmniRoute SQLite data volume from a snapshot
|
|
# created by bin/snapshot-data.sh. Used by the data-layer incident runbook
|
|
# (docs/INCIDENT_RESPONSE.md §4.4) after stopping writers.
|
|
#
|
|
# Safety: takes a pre-restore snapshot of the CURRENT data, refuses to run
|
|
# unattended without --yes, and verifies the snapshot before overwriting.
|
|
set -euo pipefail
|
|
SCRIPT_NAME="restore-data"
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_ops-common.sh"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: bin/restore-data.sh <snapshot-id> [--data-dir <path>] [--yes|-y] [-h|--help]
|
|
|
|
Restores storage.sqlite (and any sibling *.sqlite) from a snapshot. The current
|
|
data is first copied to $DB_BACKUPS_DIR/pre-restore_<UTC> as a safety net.
|
|
<snapshot-id> is a timestamp/sha, a snapshot dir name, or a path (see snapshot-data.sh).
|
|
Stop OmniRoute before running, and restart it afterwards.
|
|
EOF
|
|
}
|
|
|
|
ID=""
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--yes | -y) ASSUME_YES=1; shift ;;
|
|
--data-dir) ops_set_data_dir "${2:?--data-dir needs a value}"; shift 2 ;;
|
|
-h | --help) usage; exit 0 ;;
|
|
-*) ops_die "unknown argument: $1 (see --help)" ;;
|
|
*) ID="$1"; shift ;;
|
|
esac
|
|
done
|
|
|
|
[ -n "$ID" ] || ops_die "snapshot id required (see --help)"
|
|
snap="$(ops_find_snapshot "$ID")"
|
|
ops_log "restore source: $snap → $OMNIROUTE_DATA_DIR"
|
|
ops_confirm "Overwrite storage.sqlite at $OMNIROUTE_DATA_DIR from $snap?" || ops_die "aborted"
|
|
|
|
# Pre-restore safety copy of the live data.
|
|
if [ -f "$OMNIROUTE_SQLITE" ]; then
|
|
safety="$OMNIROUTE_BACKUPS_DIR/pre-restore_$(date -u +%Y%m%dT%H%M%SZ)"
|
|
mkdir -p "$safety"
|
|
if command -v sqlite3 >/dev/null 2>&1; then
|
|
sqlite3 "$OMNIROUTE_SQLITE" "VACUUM INTO '$safety/storage.sqlite'" \
|
|
|| cp -a "$OMNIROUTE_SQLITE" "$safety/storage.sqlite"
|
|
else
|
|
cp -a "$OMNIROUTE_SQLITE" "$safety/storage.sqlite"
|
|
fi
|
|
ops_log "current data saved to $safety"
|
|
fi
|
|
|
|
mkdir -p "$OMNIROUTE_DATA_DIR"
|
|
# Drop stale WAL/SHM so the restored DB is authoritative, then copy in.
|
|
rm -f "$OMNIROUTE_SQLITE" "${OMNIROUTE_SQLITE}-wal" "${OMNIROUTE_SQLITE}-shm"
|
|
cp -a "$snap/storage.sqlite" "$OMNIROUTE_SQLITE"
|
|
|
|
# Restore sibling DBs captured in the snapshot.
|
|
for f in "$snap"/*.sqlite; do
|
|
[ -e "$f" ] || continue
|
|
[ "$(basename "$f")" = "storage.sqlite" ] && continue
|
|
cp -a "$f" "$OMNIROUTE_DATA_DIR/"
|
|
done
|
|
|
|
ops_log "restore complete — restart OmniRoute to pick up the restored data"
|