News & Updates

How to Dump a Supabase Database Remotely: A Step‑by‑Step Guide

By Spencer Vaughn 6 min read 4397 views

How to Dump a Supabase Database Remotely: A Step‑by‑Step Guide

Supabase makes it simple to spin up a PostgreSQL database with a click of a button. But when you’re ready to back up, migrate, or inspect your data, you’ll need a reliable way to dump the entire database. A Supabase DB Dump can be created from anywhere—your laptop, a CI pipeline, or a cloud server—without touching the Supabase web console.

Why Dump Your Supabase Database?

A remote dump gives you a portable, offline snapshot of every table, schema, and function. It’s essential for:

  • Version control of database schema changes.
  • Seamless migration to another Supabase project or a different hosting provider.
  • Compliance and archival purposes.
  • Debugging data issues in a safe, isolated environment.

Choosing the Right Dump Tool for Supabase DB Dump

The most common choice is PostgreSQL’s built‑in pg_dump. It’s fast, feature‑rich, and ships with every PostgreSQL installation. Alternatives like pg_dumpall or third‑party tools (e.g., pg_dump2csv) exist, but for a standard Supabase DB Dump you’ll rarely need them.

Preparation: Gather Connection Details

Every Supabase instance exposes a connection string. In the Supabase dashboard, navigate to Settings > Database > Connection String. It looks like:

postgres://user:password@db.supabase.co:5432/project_id

Keep the credentials safe; you’ll need the host, port, database name, username, and password.

Step 1: Install PostgreSQL Client Utilities

If you’re on macOS, brew install libpq installs pg_dump without a full PostgreSQL server. Linux users can use their package manager; Windows users can download the PostgreSQL installer and keep the client tools in their PATH.

Step 2: Configure Environment Variables (Optional but Safer)

To avoid exposing credentials in command history, export them:

export PGHOST=db.supabase.co

export PGPORT=5432

export PGDATABASE=project_id

export PGUSER=user

export PGPASSWORD=password

Now you can run pg_dump without repeating the string.

Step 3: Execute the Dump

Run pg_dump with flags tailored to your needs. A common command for a full dump, including schema and data, is:

pg_dump -h $PGHOST -p $PGPORT -U $PGUSER -d $PGDATABASE -F c -b -v -f /tmp/supabase_dump.sqlc

Explanation of flags:

  • -F c – Custom format, ideal for later restore.
  • -b – Include large objects.
  • -v – Verbose output for progress.
  • -f – Output file path.

After completion, you’ll have a compressed archive you can copy or archive.

Step 4: Verify the Dump (Optional but Recommended)

Restore the dump to a local temporary database to confirm integrity:

createdb temp_restore

pg_restore -U $PGUSER -d temp_restore /tmp/supabase_dump.sqlc

Run a quick query against temp_restore to ensure tables exist and data is intact.

Advanced: Automating the Dump in CI/CD

Many teams embed database backups in deployment pipelines. In GitHub Actions, you can add a job that pulls pg_dump from a Docker image:

- name: Dump Supabase DB

run: |

docker run --rm -e PGPASSWORD=${{ secrets.SUPABASE_PASS }} \

-v $PWD:/dump \

postgres:15 \

pg_dump -h db.supabase.co -U ${{ secrets.SUPABASE_USER }} -d ${{ secrets.SUPABASE_DB }} \

-F c -b -v -f /dump/supabase_${{ github.sha }}.sqlc

Store the file in a secure artifact or upload it to cloud storage.

Restoring a Supabase DB Dump

When you need to bring the dump back into Supabase (for a new project or local dev), create a fresh Supabase instance and run:

pg_restore -h newdb.supabase.co -U newuser -d newdb -v /path/to/supabase_dump.sqlc

Supabase’s free tier supports restores of up to 500 MB. For larger dumps, consider splitting or upgrading.

Troubleshooting Common Issues

  • Authentication errors: Double‑check the password and ensure the user has CONNECT privileges.
  • Connection timeouts: Supabase’s databases run behind a firewall; ensure your IP is whitelisted in the project settings.
  • Large objects missing: Include the -b flag or use pg_restore --no-privileges to bypass permissions issues.

FAQ

Q: Can I dump only a subset of tables?

A: Yes. Add -t tablename for each table. Combine with --exclude-table to skip others.

Q: Is there a way to automate incremental dumps?

A: PostgreSQL’s pg_dump doesn’t support incremental backups out of the box. Instead, use logical replication or a third‑party tool like wal-g for continuous archiving.

Q: Do I need a full database dump for migrations?

A: A full dump is the simplest approach. For schema‑only migrations, use pg_dump -s to export just the structure.

Q: Where can I safely store the dump file?

A: Encrypt the file with openssl aes-256-cbc -salt and upload it to a secure bucket or version‑controlled archive.

Supabase Schema - Supabase Schema Visualizer - Made with Vue.js
Using Supabase as your Database for Remix | SaasRock Documentation
Error while using supabase db remote commit · supabase · Discussion ...
sync remote db changes to local - Supabase

Written by Spencer Vaughn

Spencer Vaughn is a Senior Journalist covering general news, social developments, and cultural trends. With a background in daily reporting and long-form features, he examines both the immediate story and its wider context, making complex topics accessible to a broad audience.


You Might Like