TECHNICAL GEMS

Backing up Supabase

How to Back Up Everything in Your Supabase Account

Backing up your entire Supabase account involves two main components:

  • Backing up your PostgreSQL database (all schema and data)
  • Backing up your storage buckets (files)

Below are the recommended approaches for each, including both built-in and manual methods.

Database Backups

1. Use Supabase’s Built-in Scheduled Backups

  • Supabase automatically performs daily backups of your database.
  • You can access and restore these backups from the “Scheduled backups” section in your Supabase Dashboard.
  • Backup retention depends on your plan:
    • Pro Plan: last 7 days
    • Team Plan: last 14 days
    • Enterprise Plan: last 30 days
  • These backups can be restored directly from the dashboard, but downloading them is limited (especially for large databases over 15GB).

2. Manual Backup Using Supabase CLI

To generate a logical backup yourself (recommended for maximum control):

  • Install the Supabase CLI and Docker Desktop.
  • Get your database connection string from the Supabase dashboard.
  • Use the CLI to dump roles, schema, and data:
bashsupabase db dump --db-url [CONNECTION_STRING] -f roles.sql --role-only
supabase db dump --db-url [CONNECTION_STRING] -f schema.sql
supabase db dump --db-url [CONNECTION_STRING] -f data.sql --use-copy --data-only

Replace [CONNECTION_STRING] with your actual database connection string.

3. Manual Backup Using pg_dump

You can also use the standard PostgreSQL pg_dump tool:

bashpg_dump --inserts --column-inserts --username=myuser --host=db.myproject.supabase.co --port=5432 mydatabase > database-dump.sql

Or using a connection string:

bashpg_dump 'postgresql://myuser:mypassword@db.myproject.supabase.co:5432/mydatabase' > database-dump.sql

Replace credentials with your actual values.

Storage Buckets Backup

Supabase storage buckets (files) are not included in database backups. To back these up:

  • Use scripts or tools to download all files from your buckets.
  • There is no built-in one-click backup for storage buckets, so you must automate this yourself (e.g., using the Supabase Storage API or a custom script).

Automating Backups

  • For regular backups, set up a cron job or scheduled task to run your backup scripts (for both database and storage).
  • Consider using third-party tools or backup services (e.g., Ottomatik) for automated and managed backups.

Summary Table

What to Back UpMethodTool/Location
Database (schema & data)Scheduled backups (automatic)Supabase Dashboard
Manual logical backup (recommended)Supabase CLI or pg_dump
Storage Buckets (files)Manual download (script/API)Supabase Storage API

Best Practice:
Combine both database and storage backups for a complete backup of your Supabase project. Automate the process where possible and store backups securely in multiple locations.

If you need step-by-step instructions for any method, let me know which approach you prefer.


On the Supabase Free Plan, automatic backups are not provided—this feature is only available on paid plans. To back up your data, you must do it manually. Here’s how:

Database Backup (Manual):

  • Use the Supabase CLI or connect directly to your project’s PostgreSQL database and run pg_dump to export your schema and data.
  • You can find your database connection details in the Supabase dashboard under Project Settings → Database.
  • Example using pg_dump:
bashpg_dump 'postgresql://username:password@host:port/database' > backup.sql

Replace the connection string with your actual credentials.

Storage Buckets Backup:

  • There is no built-in tool for storage bucket backups on the free plan.
  • Write a script to download all files from your storage buckets using the Supabase Storage API.

Summary:

  • No automatic backups on the free plan.
  • Manual backups are possible using pg_dump for the database and scripts for storage files.
  • If you ever need to restore from an automatic backup, you would have to upgrade to a paid plan temporarily.

You cannot perform a full database dump (schema and data) directly from the Supabase Query page. However, you can export the results of SQL queries or individual tables as CSV files from the Query (SQL Editor) page:

  • To export a table:
    1. Go to the SQL Editor in your Supabase dashboard.
    2. Run a query like SELECT * FROM table_name;.
    3. After the results appear, click the “Download CSV” button to export the data.

This method lets you export table data, but it does not export the full database schema, relationships, or all tables at once—only the results of the specific query you run. For a full backup (including schema), you must use tools like pg_dump from your terminal, not from the Query page.

Summary:

  • The Query page lets you export query results or single tables as CSV files.
  • For a full database dump, use external tools like pg_dump with your database connection string.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *