Files
loki/scripts/db/restore.sh
T
Mao NakamotoandClaude Opus 4.8 c6bc058cb4 chore: purge Vercel / Neon / managed-Supabase across the codebase
Self-hosted on Hetzner is the only reality now; the leftover references were
stale at best and a security hole at worst. Thorough sweep across code, config,
scripts, docs, and comments (84+ files). Self-hosted supabase.orangecat.ch is
kept; historical migration records stay accurate.

Functional / security fixes:
- cron-auth: prod detection was process.env.VERCEL (unset on the box!), so the
  fail-closed 'CRON_SECRET unset -> 503' gate never fired in production. Now
  keys on NODE_ENV=production. (security)
- auth trustHost: dropped the dead process.env.VERCEL===1 branch.
- AppFooter: read the baked-in build SHA instead of VERCEL_GIT_COMMIT_SHA/ENV.
- project bootstrap: removed 'neon projects create' + the Vercel deploy brief;
  DB option is now self-hosted Postgres, deploy guidance is the self-hosted flow.
- db-url: removed the legacy NEON_DATABASE_URL* fallbacks (+ updated its test).

Infra / removals:
- deleted .github/workflows/vercel-deploy.yml and scripts/db/dump-from-{neon,supabase}.sh.
- stripped NEON_* env fallbacks from db dump/restore/sync scripts.

User-facing:
- desktop offline overlay no longer blames a 'Vercel hiccup'; privacy page +
  PRIVACY_POLICY subprocessors now say Hetzner self-hosted / self-hosted Postgres.

Plus ~50 comment/doc rewrites (Vercel -> the cloud host/the box; Neon -> Postgres).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 10:46:43 +02:00

40 lines
981 B
Bash
Executable File

#!/usr/bin/env bash
# Restore a pg_dump plain SQL backup produced by scripts/db/dump.sh
#
# Usage:
# DATABASE_URL=postgresql://... ./scripts/db/restore.sh backup.sql.gz
#
# WARNING: restores into the target database as-is. Prefer an empty DB or
# use --clean manually on a custom dump if you need replace semantics.
set -euo pipefail
if [ $# -lt 1 ]; then
echo "Usage: DATABASE_URL=... $0 <backup.sql.gz>" >&2
exit 2
fi
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
if [ -z "${DATABASE_URL:-}" ] && [ -f "$ROOT/.env.local" ]; then
set -a
# shellcheck source=/dev/null
source "$ROOT/.env.local"
set +a
fi
URL="${DATABASE_URL:-}"
if [ -z "$URL" ]; then
echo "ERROR: set DATABASE_URL (direct connection) before running." >&2
exit 2
fi
BACKUP="$1"
if [ ! -f "$BACKUP" ]; then
echo "ERROR: file not found: $BACKUP" >&2
exit 2
fi
echo "Restoring $BACKUP into target database ..."
gunzip -c "$BACKUP" | psql "$URL" -v ON_ERROR_STOP=1
echo "Done."