Files
collective-lists/infra/scripts/restore.sh
Oier Bravo Urtasun 973f9e413c Fase 0: scaffold monorepo, SvelteKit skeleton, and dev infrastructure
- Turborepo + pnpm workspaces with apps/web and packages/types
- SvelteKit app: Tailwind, Paraglide i18n (en/es), keycloak-js, Supabase client,
  auth/collective stores, PWA service worker skeleton, all route placeholders
- packages/types: domain types (User, Collective, ShoppingList, etc.) and
  database.ts placeholder for generated types
- Justfile with dev, db-*, kc-*, build, backup, restore, deploy recipes
- infra/docker-compose.dev.yml: Postgres 15, GoTrue, PostgREST, Realtime v2.83,
  Storage, Kong (port 8001), Studio, Keycloak 24
- infra/docker-compose.prod.yml, kong.yml, db-init scripts, backup/deploy scripts
- keycloak/realm-export.json with colectivo realm and 5 dev test users
- supabase/config.toml and seed.sql with sample collective and items
- GitHub Actions: ci.yml (lint+typecheck+build) and deploy.yml (GHCR + SSH)
- .env.example documenting all required variables
- Fixed docker-compose issues: Studio image tag, Kong port conflict (8001),
  internal role passwords init script, Realtime METRICS_JWT_SECRET/APP_NAME

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 14:37:51 +02:00

38 lines
1014 B
Bash
Executable File

#!/usr/bin/env bash
# restore.sh — restore a backup file to a service
# Usage: just restore supabase backups/postgres-20240101T030000Z.dump.gz
#
# WARNING: This is destructive. It will drop and re-create the database.
# Only run on a stopped or isolated instance.
set -euo pipefail
SERVICE="${1:?Usage: restore.sh <service> <file>}"
FILE="${2:?Usage: restore.sh <service> <file>}"
if [ ! -f "$FILE" ]; then
echo "File not found: $FILE" >&2
exit 1
fi
COMPOSE="docker compose -f $(dirname "$0")/../docker-compose.prod.yml"
case "$SERVICE" in
supabase|postgres|db)
echo "==> Restoring PostgreSQL from $FILE"
echo " WARNING: This will overwrite all data. Press Ctrl-C within 5s to abort."
sleep 5
if [[ "$FILE" == *.gz ]]; then
gunzip -c "$FILE" | $COMPOSE exec -T db psql -U postgres
else
$COMPOSE exec -T db psql -U postgres < "$FILE"
fi
echo "==> Restore complete"
;;
*)
echo "Unknown service: $SERVICE. Use 'supabase'." >&2
exit 1
;;
esac