Supabase-DB Backup and Restore
Hi Community,
I’m currently trying to back up my self‑hosted Supabase Postgres database. Right now, I’m using pg_dump and uploading the .dump file to S3. For restoration, I drop the database and restore it from the dump.
While the Postgres restore completes successfully, the supabase‑storage container fails to display files from my S3 bucket. I get errors indicating that the storage schema wasn’t backed up.
Can anyone advise:
1. How to fully back up a Supabase database, including all schemas (auth, public, storage, etc.) and data?
2. How to ensure the storage buckets and objects are preserved so that the supabase‑storage container can list and serve the files correctly?
Any guidance—or sample scripts—on achieving a complete backup and restore with everything working again would be greatly appreciated.
Thanks in advance!
4 Replies
You have to back up file data on "s3" on your own. It can't be done with sql operations You would get the storage meta in storage.objects only.
The migration guides give examples of scripts to do that.
Thanks for your response. @Maik and I are working together, trying to get backups working with our self-hosted instance. The issue is not that S3 files are not updated (we are already doing this successfully) but that the backup restore seems to complete successfully but when starting the
supabase-storage
docker container it fails, saying that the buckets
table does not exist. That's the reason we can't see the files and now are unsure how we can ensure a complete backup that of the database.
We know there are some scripts running when starting the docker image of Supabase database. Maybe it is some sort of permission issue why not all data seems to be backed up / restored? Or are you sure we should be able to just use pg_dump
and restore process as described in the migration guide and it should work out of the box?I was strictly referring to copying the actual file data versus the storage schema as pg_dump should be able to handle the schema.
https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore
https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore#migrate-storage-objects
These sections were what I was referring to.
I don't know anything about self-hosting though.
Pg_dump should work with it like the hosted instances though as it is dealing with just the database.
Thanks for your response. We ended up just creating a backup of all relevant docker volumes, which was the only way that reliably worked without any errors during restoring.