Backups [database & storage] without supabase-cli #22200
-
|
Database backups are well documented, but since the project evolve over time,
CONSTRAINT: the solution must work in hosted and self-hosted environment DatabaseBackuppg_dump -h xxxxx.pooler.supabase.com -p 5432 -d postgres -U postgres.xxxxx --schema-only > backup.sqlRestorepsql -h xxxxx.pooler.supabase.com -p 5432 -d postgres -U postgres.xxxxx < backup.sql |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
|
Would love to know the answer too |
Beta Was this translation helpful? Give feedback.
-
|
Same here. I would like to know what are the steps to do backup and restore. |
Beta Was this translation helpful? Give feedback.
-
|
Same here. Reading 3rd thread, no answer for this. |
Beta Was this translation helpful? Give feedback.
-
|
@kiwicopple Could we have your opinion on the topic? |
Beta Was this translation helpful? Give feedback.
-
|
@theranajayant @tristdrum @djshubs @neiled This is my procedure to backup supabase instance with classic tools.
The re-import process is the opposite, using I'm sharing with you the script I'm using to backup schemas. You can select which schema you want to include in your backup but also specify if you want You can set up environment variables ( ./pg_backup.sh --DB_HOST=<region>.pooler.supabase.com --DB_PORT=6543 --DB_NAME=postgres --DB_USER=postgres.<id> --DIR=./backupIf you have any tips, please share |
Beta Was this translation helpful? Give feedback.
-
|
After many hours of struggling, I finally have a working backup and restore system for my self hosted Supabase. There were several roadblocks that took awhile to find the solutions for:
Here are the scripts that backup and restore supabase fully, including all schemas. The only thing missing would be moving your actual storage files if you are using storage This script expects you to have postgresql-client tools installed on your docker host https://gist.github.com/highway11/747c45e8fb6c8df73f562e859801dd2d You may still see a couple of errors on the restore procedure, but I think these are inconsequential and all the data is there |
Beta Was this translation helpful? Give feedback.
-
|
The accepted answer is still the right blueprint. A few additions for people landing here from search in 2026 — these are the things that bit people later in this thread, plus what I'd add after running this setup in production: 1. The rclone signature errors reported above (@igorlanko, @Schotsl). Versions after 1.67.0 (reports in this thread start at 1.68.0) had trouble against Supabase's S3 endpoint, while pinning an older release like 1.62 (as @lautaroPH suggested) worked. If you'd rather not pin rclone, the plain AWS CLI/SDK talks to the endpoint fine — that's what I ended up using: aws s3 sync s3://<your-bucket> ./storage-backup/<your-bucket> \
--endpoint-url "https://<project-ref>.storage.supabase.co/storage/v1/s3" \
--region <project-region>Credentials come from Dashboard → Storage → Settings → S3 Access Keys. Note these keys bypass RLS — treat them like a service-role key and keep them out of client code. 2. Match your 3. Use the Session Pooler connection string (Project Settings → Database → Connection string → Session pooler), not the direct 4. A backup you've never restored is a guess. The cheapest verification is restoring into a throwaway Postgres and spot-checking row counts: docker run --rm -d --name restore-test -e POSTGRES_PASSWORD=test -p 5433:5432 postgres:17
pg_restore --clean --if-exists --no-owner \
--dbname "postgresql://postgres:test@localhost:5433/postgres" dump.pgcustom
psql "postgresql://postgres:test@localhost:5433/postgres" \
-c "select relname, n_live_tup from pg_stat_user_tables order by 2 desc limit 10;"
docker rm -f restore-testIf your schema uses extensions (e.g. 5. Budget for egress. Every dump + file download counts as uncached egress on your Supabase bill ($0.09/GB past your plan's allowance; the Free plan's 5 GB/month allowance is enforced through a fair-use flow — notice, then a grace period, then restrictions, never a charge — so recurring large backups aren't viable on Free). Weekly is usually the sane default once your data is tens of GB. Full disclosure: I'm the author of an open-source CLI that grew out of exactly the problems in this thread. Longer write-ups of the manual approach: https://backupdrill.com/guides/supabase-backup and, for the restore-verification step, https://backupdrill.com/guides/test-supabase-backup-restore |
Beta Was this translation helpful? Give feedback.
@theranajayant @tristdrum @djshubs @neiled
This is my procedure to backup supabase instance with classic tools.
I'm using only auth + postgres + storage in supabase, no other features will be covered.
psql/pg_dump. The most import schema (IMO) are: auth,public,storagerclone sync(you have torclone configbefore)The re-import process is the opposite, using
psql/pg_restore, it works well with data but, you could be blocked for schema as supabase protectsuperuserrole. You can also re-upload all buckets you saved using rclo…