Back up and restore
Back up your Supabase database and Storage files, then practise restoring them into a separate project.
Give your agent this prompt
Prepare backups for my database and every Storage bucket.
Follow https://coremvp.com/en/docs/deployment/after-launch/back-up-and-restore.md and its prerequisites.
Ask me to approve the source, backup location and named destination before copying customer data or creating a project, and separately before deletion.
Finish when local backup files and restored table and bucket inventories match, with a readable sample per bucket and access checks.
Report what changed, the check results and anything you could not run.What Supabase keeps for you
| Plan | Database backups |
|---|---|
| Free | None. Export your own (below). |
| Pro and above | Daily backups kept for 7 days or more by plan; point-in-time recovery replaces daily backups when enabled |
See Supabase backups. Database backups do not include your Storage files, such as uploaded pictures and documents. Copy those separately.
Before exporting, install Docker and psql, sign in to the Supabase CLI and link
the source project. Follow the Supabase backup and restore prerequisites
and check the linked project before running the commands.
Export the database
bunx supabase db dump --linked -f roles.sql --role-only
bunx supabase db dump --linked -f schema.sql
bunx supabase db dump --linked -f data.sql --use-copy --data-only \
--exclude storage.buckets --exclude storage.objectsExclude bucket and object rows because the restore recreates buckets and uploads their file bytes separately. Restoring those rows would leave paths occupied before the files are uploaded. Keep these dumps private and off Git.
Copy Storage files
Repeat this command for each bucket, replacing user-files with its name.
The template creates a private user-files bucket. Record each bucket’s
access settings and each object’s exact path and owner ID privately next to
the backup. Use that inventory to recreate the buckets and restore ownership.
bunx supabase storage cp -r ss:///user-files ./storage-backup/user-files --experimental --linkedPractise a restore
After approval, create the named throwaway Supabase project. In its Connect panel, open the
session pooler's connection parameters and copy the host, port and user.
psql asks for the database password, so it never enters your shell
history:
psql --single-transaction --variable ON_ERROR_STOP=1 \
--host <host> --port <port> --username <user> --dbname postgres --password \
--file roles.sql --file schema.sql \
--command 'SET session_replication_role = replica' \
--file data.sqlBefore uploading, verify the destination project ID in the Dashboard and in the CLI link; never use --linked until it points to the approved destination. For private user-files, retain a secure mapping of each object path to its original owner when backing up. Restore Auth users with their original IDs. Before re-uploading files, recreate the matching buckets with their original access settings and restore the custom Storage and Auth policies using the Supabase special restore considerations. Then upload each private file through an authenticated session for its original owner to the matching bucket. Dashboard uploads do not preserve the user owner. Check the restored object ownership, bucket settings and permissions as well as file contents; if the owners or IDs cannot be restored, the private-file restore is not complete. See Storage ownership.
Never restore into your production project to test.
Follow the special restore considerations to restore migration history separately.
Check it works
Check the local backup files, then compare the intended table and bucket inventories with the restored project. Check rows in each table and a readable sample from each bucket. For a private file, verify the expected user can access it and an unrelated user cannot. Ask for separate approval before deleting the throwaway project.
Follow Supabase's restore guide for a real restore.
Was this page helpful?