A GitHub Action that backs up a Supabase database on a schedule and keeps the copy outside Supabase. Then it restores that copy into a throwaway Supabase database on the runner and counts every table against the file.
A plain backup workflow turns green when the dump command exits 0. A file that was cut off halfway, a dump with no rows in it and a dump without your users all exit 0 as well. This run turns green only when the copy restored and every table came back with the rows the file holds.
- uses: reeve-page/supabase-backup-action@v1
with:
db-url: ${{ secrets.SUPABASE_DB_URL }}- Create a private repository for the backups. The data file holds your users' email addresses, so give it a repository of its own.
- In your Supabase project, click Connect and copy the Session pooler
string. Its user is
postgres.<project-ref>, its host ends inpooler.supabase.com, and its port is5432. Put your database password into it. - In the repository, open Settings, then Secrets and variables, then Actions,
and add a secret called
SUPABASE_DB_URLholding that string. - Save
examples/backup.ymlas.github/workflows/supabase-backup.yml. - Run it once by hand from the Actions tab, so the first run happens while you are watching.
The direct connection string (db.<project-ref>.supabase.co) fails on GitHub's
runners: it uses IPv6 unless you pay for the IPv4 add-on, and the runners only
reach IPv4. Supabase's
backup and restore guide
says to use the Session pooler string by default.
- Dumps roles, schema and data into
roles.sql,schema.sqlanddata.sqlwith the threesupabase db dumpcommands from Supabase's backup and restore guide. The action reads your project's Postgres version from the server first, and the Supabase CLI runs thepg_dumpfor that version. The CLI leaves a few statements on Supabase's own roles inroles.sqlthat a new project refuses to run, such as a setting onsupabase_adminand, on Postgres 17, grants of Postgres settings. They stop Supabase's restore command, so the action comments them out the way the CLI already does for those roles' other lines. - Checks the files.
data.sqlmust end with pg_dump'sPostgreSQL database dump completeline, which a file cut off partway never has. It must also hold aCOPY "auth"."users"block, where your accounts live. - Restores them into a fresh Supabase database on the runner
(
supabase db start, on your project's Postgres major version), with thepsqlcommand from the same guide. - Counts the rows of every table in the restored database and compares
each count with the rows
data.sqlholds for that table. The result goes intorestore-check.tsvbeside the three files and into the run's summary. - Keeps the folder as a workflow artifact, in an S3-compatible bucket, or in the workspace for your own steps.
- Fails the run when the check did not pass. The copy is kept either way.
| Input | Default | What it does |
|---|---|---|
db-url |
(required) | The Session pooler connection string, from a secret. |
destination |
artifact |
artifact, s3, or none to leave the files in the workspace. |
retention-days |
7 |
Days GitHub keeps the artifact. |
s3-bucket |
Bucket name, when destination is s3. |
|
s3-prefix |
supabase-backups/ |
Each run writes to <prefix><timestamp>/. |
s3-endpoint |
For a store that is not AWS, e.g. https://<account-id>.r2.cloudflarestorage.com. |
|
s3-region |
auto when s3-endpoint is set, otherwise AWS_REGION or us-east-1. |
|
s3-access-key-id |
From a secret. Leave empty to use credentials already in the job, such as aws-actions/configure-aws-credentials. |
|
s3-secret-access-key |
From a secret. | |
verify |
true |
false skips the restore check. |
postgres-version |
Your project's Postgres major version. Leave it empty and the action reads it from the server. | |
path |
supabase-backup |
Folder in the workspace the files are written to, one timestamped folder per run. |
cli-version |
latest |
Supabase CLI version. |
| Output | Value |
|---|---|
dir |
The folder holding the three files and restore-check.tsv. |
files |
The three files, space-separated. |
check |
passed, failed, unchecked when the check could not run, skipped when off. |
artifact-url |
Download URL of the artifact. |
s3-uri |
Where the copy landed in the bucket. |
As an artifact (the default), the folder is zipped and kept with the run for
retention-days. On a private repository, artifacts count against your
account's storage: GitHub Free includes
500 MB,
shared with GitHub Packages, and once an account with no payment method uses it
up, further use is blocked. Seven nightly copies take seven times the zipped
size of one, so look at the size of the first artifact before you raise the
retention.
In a bucket, any S3-compatible store works: AWS S3, Cloudflare R2,
Backblaze B2, MinIO. examples/backup-r2.yml is the
R2 version. Give the key write access to that one bucket and nothing else, and
set a lifecycle rule on the bucket to delete old copies, because the action
never deletes anything.
With none, the files stay in the workspace at the dir output for steps
of your own, such as committing them to the repository.
Every run downloads your whole database, and Supabase counts that download as egress, against an allowance shared by every project in the organization. On 4 October 2026 Supabase's pricing page gave the free plan 5 GB of egress a month and a 500 MB database per project, and Pro 250 GB of egress. A daily backup of a 500 MB database moves about 15 GB a month, three times the free allowance before your app has served a request. Weekly fits at every size the free plan allows:
- cron: '17 3 * * 0' # SundaysThe arithmetic for every size is in the article this action grew out of.
The restore check runs entirely on the runner and downloads nothing from your project. It costs runner minutes, which are free on public repositories and count against your plan's minutes on private ones.
- That anyone can sign in. The check proves the rows in
auth.userscame back. A sign-in against a restored copy is the only test of the passwords, and the restore drill shows how to run one. - Anything about uploaded files. Supabase Storage keeps each file outside the database, so a dump holds the row describing a file and never the file. Backing up Storage is a job of its own.
- That encrypted columns decrypt. Vault secrets and pgsodium columns restore as ciphertext, and the root key is never in a backup. Supabase's guide explains how to copy the key to a new project.
- Your
pg_cronjobs. The extension comes back with the schema, but the jobs live incron.job, whose rows pg_dump leaves out of this dump, so a restored project runs none of them. Keep yourcron.schedulecalls in a migration or a file you can run again. - Anything outside the database: Edge Functions, auth provider settings, API keys and project settings.
The throwaway database runs the auth and storage versions that ship with the
Supabase CLI, which can be older than the ones your hosted project runs. If the
check fails on a column in auth or storage that does not exist, the CLI is
behind your project; keep cli-version at latest.
The run's summary shows the first error, and the Restore check step has the last twenty lines of the replay.
- A permission error naming
supabase_adminorcli_login_postgres. Supabase's guide covers both in its troubleshooting notes. A restore into a new project runs the same command, so expect it to stop at the same line. no 'PostgreSQL database dump complete' line. The dump was cut off. The dump step's log has the reason.no COPY "auth"."users" block. The data dump did not reach your users. The action's own dump always includes them, so this comes from adata.sqlmade some other way.- A table with fewer rows than the file holds. The replay did not load what the file contains. The summary names the table.
unchecked means the check could not run at all, for example on a self-hosted
runner without Docker. It fails the run too, and the summary says what was
missing.
Create a new Supabase project, download the copy, and replay it with the command from Supabase's guide:
psql \
--single-transaction \
--variable ON_ERROR_STOP=1 \
--file roles.sql \
--file schema.sql \
--command 'SET session_replication_role = replica' \
--file data.sql \
--dbname "<the new project's Session pooler string>"How to restore a Supabase backup goes through it step by step.
scripts/check.sh <folder> checks any folder holding the three files, on any
machine with Docker, psql and the Supabase CLI. It exits 0 when the copy
passed, 1 when it failed and 2 when it could not run.
- Free Supabase backup with a GitHub Action, and the catch
- Test your Supabase backup before the day you need it
- Why your Supabase dump has no users in it
Reeve does this as a service for Supabase databases. Copies are kept off-platform on your plan's schedule, every copy is checked as it is taken, and a restore is a button.
MIT