# Supabase Database Backup on the Free Tier⚡

Since automated backups aren't available on the Supabase Free Tier, I wanted a simple workflow I could run before every migration.

* * *

## There Are 3 Ways to Backup a Supabase Database

If you're on the Supabase Free Tier, these are the three most practical approaches:

## 1️⃣ Supabase CLI

The official Supabase method.

```bash
supabase db dump
```

Good for:

*   Official workflow
    
*   Exporting schema and data
    
*   CI/CD integrations
    

⚠️ Requires Docker.

* * *

## 2️⃣ pg\_dump (My Preferred Method)

The standard PostgreSQL backup tool.

```bash
pg_dump
```

Good for:

*   Quick backups before migrations
    
*   No Docker required
    
*   Fast restores
    
*   Works directly with Supabase
    

This is the method I personally use.

* * *

## 3️⃣ GitHub Actions (Automated Backups)

Want backups without remembering to create them?

Use GitHub Actions.

Benefits:

✅ Daily automated backups

✅ Backup history stored in Git

✅ No manual work

✅ Easy disaster recovery

I wrote a complete guide here:

👉 [https://blog.akashy.com.np/automate-supabase-database-backups-using-github-actions](https://blog.akashy.com.np/automate-supabase-database-backups-using-github-actions)

⚠️ Never store database backups in a public repository.

* * *

# Option 1: Backup Using Supabase CLI

Install the Supabase CLI:

```bash
npm install supabase --save-dev
```

or

```bash
npm install -g supabase
```

* * *

## Docker Requirement

Supabase CLI backup commands require Docker.

Download Docker Desktop:

👉 https://www.docker.com/products/docker-desktop/

Install and start Docker.

Verify:

```bash
docker --version
```

and

```bash
docker ps
```

* * *

## Create Backup

Full dump:

```bash
supabase db dump \
--db-url "YOUR_DB_URL" \
-f backup.sql
```

Separate dumps:

```bash
supabase db dump \
--db-url "YOUR_DB_URL" \
--role-only \
-f roles.sql
```

```bash
supabase db dump \
--db-url "YOUR_DB_URL" \
-f schema.sql
```

```bash
supabase db dump \
--db-url "YOUR_DB_URL" \
--data-only \
--use-copy \
-f data.sql
```

* * *

# Option 2: Backup Using pg\_dump

This is my preferred approach.

No Docker.

No extra setup beyond PostgreSQL tools.

* * *

## Install PostgreSQL Tools

Verify installation:

```bash
pg_dump --version
```

Expected:

```bash
pg_dump (PostgreSQL) 17.x
```

* * *

## Get Your Database Connection String

Inside Supabase:

```text
Settings
→ Database
→ Connection String
```

Use the **Direct Connection** endpoint:

```text
postgresql://postgres:PASSWORD@db.xxxxx.supabase.co:5432/postgres
```

* * *

## Create Backup

Basic backup:

```bash
pg_dump \
"postgresql://USER:PASSWORD@HOST:5432/postgres" \
> backup.sql
```

* * *

## Recommended Backup

I prefer PostgreSQL's custom format:

```bash
pg_dump \
"postgresql://USER:PASSWORD@HOST:5432/postgres" \
--schema=public \
-F c \
-f backup.backup
```

### Why?

```text
--schema=public
```

Backs up only application tables.

Excludes Supabase-managed schemas like:

```text
auth
storage
realtime
supabase_functions
```

* * *

```text
-F c
```

Creates a compressed PostgreSQL backup.

Benefits:

*   Smaller file size
    
*   Faster restore
    
*   More reliable
    
*   Supports partial restores
    

* * *

# My Backup Strategy

Before every migration:

```powershell
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"

pg_dump `
"postgresql://USER:PASSWORD@HOST:5432/postgres" `
--schema=public `
-F c `
-f "backups\backup_$timestamp.backup"
```

Result:

```text
backups/
├── backup_2026-06-23_10-15-20.backup
├── backup_2026-06-25_08-32-10.backup
├── backup_2026-06-27_14-41-55.backup
```

Now every migration has a rollback point.

* * *

# Verify the Backup

Check contents:

```bash
pg_restore -l backup.backup
```

You should see your tables listed.

Example:

```text
profiles
friends
notifications
movie_recommendations
```

If they're there, the backup is likely healthy.

* * *

# Restore a Backup

Restore using:

```bash
pg_restore \
-d "postgresql://USER:PASSWORD@HOST:5432/postgres" \
backup.backup
```

⚠️ Always test restores on a development database first.

Never test your first restore on production.

More detailed guide onmy blog here - [https://blog.akashy.com.np/restore-a-supabase-database-from-sql-backups-step-by-step-guide](https://blog.akashy.com.np/restore-a-supabase-database-from-sql-backups-step-by-step-guide)

* * *

# My Backup Checklist

Before running:

```bash
npx prisma migrate deploy
```

or

```sql
ALTER TABLE ...
```

I always:

✅ Create a backup

✅ Use timestamped filenames

✅ Verify using `pg_restore -l`

✅ Store backups outside my laptop

✅ Test restores occasionally

* * *

# Which Method Should You Choose?

| Method | Best For |
| --- | --- |
| Supabase CLI | Official workflow |
| pg\_dump | Fast manual backups |
| GitHub Actions | Automated daily backups |

My recommendation:

*   Before migrations → **pg\_dump**
    
*   Daily protection → **GitHub Actions**
    
*   Restore testing → **Local .backup files**
    

That's the setup I currently use.

* * *

# Final Thoughts

Backups feel unnecessary right up until the moment you need one.

If you're using the Supabase Free Tier:

1.  Create backups before every migration.
    
2.  Use timestamped backup files.
    
3.  Store backups outside your machine.
    
4.  Test your restores occasionally.
    
5.  Automate backups when your project grows.
    

The entire process takes less than a minute and can save hours—or days—of recovery work later.

Happy building 🚀

* * *

## Useful Links

Supabase Backup Documentation

https://supabase.com/docs/guides/platform/backups

Official CI/CD Backup Workflow

https://supabase.com/docs/guides/deployment/ci/backups

* * *

## Related Articles

### Automate Daily Supabase Backups Using GitHub Actions

👉 [https://blog.akashy.com.np/automate-supabase-database-backups-using-github-actions](https://blog.akashy.com.np/automate-supabase-database-backups-using-github-actions)

### Restore Supabase Database Backup

👉 [https://blog.akashy.com.np/restore-a-supabase-database-from-sql-backups-step-by-step-guide](https://blog.akashy.com.np/restore-a-supabase-database-from-sql-backups-step-by-step-guide)
