Back to Supabase

Transferring From Cloud To Self Host In Supabase 2oWNvW

apps/docs/content/troubleshooting/transferring-from-cloud-to-self-host-in-supabase-2oWNvW.mdx

1.26.04888 B
Original Source

For a detailed, step-by-step guide on restoring your database from the Supabase platform to a self-hosted Supabase instance, see Restore a Platform Project to Self-Hosted.

Quick reference

Back up your cloud database:

bash
supabase db dump --db-url "[CONNECTION_STRING]" -f roles.sql --role-only
bash
supabase db dump --db-url "[CONNECTION_STRING]" -f schema.sql
bash
supabase db dump --db-url "[CONNECTION_STRING]" -f data.sql --use-copy --data-only

Restore to your self-hosted instance:

bash
psql \
  --single-transaction \
  --variable ON_ERROR_STOP=1 \
  --file roles.sql \
  --file schema.sql \
  --command 'SET session_replication_role = replica' \
  --file data.sql \
  --dbname "postgres://postgres.your-tenant-id:[POSTGRES_PASSWORD]@[your-domain]:5432/postgres"