supabase start/stop no longer restores development database
Bug report
Describe the bug
Prior to supabase cli 0.16.0/1 when you started and stopped the supabase service it would dump and restore your database so that any data and schema changes would get restored. It appears that supabase stop no longer writes to the dump.sql file when you stop the service.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Run
supabase start - Make changes to the database
- Run
supabase stop - Run
supabase start - Check that changes from step 2 are still in the database.
Expected behavior
I would expect the data and schema changes to still exist after restarting the service.
Additional context
I believe this worked by writing to a file named dump.sql. Another solution could be to mount a local folder in the hose system as a volume in the container for the postgresql data folder so the database isn't ephemeral.
Any updates on this?
:tada: This issue has been resolved in version 1.8.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
We have added supabase stop --backup flag to dump and restore data from your local database when restarting. If you run into any problems with restoring the dumped data, please feel free to open a new issue.
We will likely make this flag the default behaviour once we iron out all the edge cases.
We have added
supabase stop --backupflag to dump and restore data from your local database when restarting. If you run into any problems with restoring the dumped data, please feel free to open a new issue.We will likely make this flag the default behaviour once we iron out all the edge cases.
Any idea where can we locate the local backup file? I'd like to have a permanent copy because sometimes I forget to include "--backup" and I have to restart everything again.
You can find the backup file saved as a docker volume
$ supabase stop --backup
Postgres database saved to volume: supabase_db_cli
Storage directory saved to volume: supabase_storage_cli
Stopped supabase local development setup.
$ docker inspect supabase_db_cli
[
{
"CreatedAt": "2023-04-21T16:31:04Z",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/supabase_db_cli/_data",
"Name": "supabase_db_cli",
"Options": null,
"Scope": "local"
}
]
-- backup is not working. I have to import my data every time. What should I try?
no more saved in supabase/.branches/main/dump.sql ?
no more saved in supabase/.branches/main/dump.sql ?
Yup, your local dev data is backed up physically to a docker volume by default now. Use supabase stop --no-backup if you don't want to save a backup.
You can still get a logical backup of the local database manually via pg_dump or
supabase db dump --db-url postgres://postgres:postgres@localhost:54322/postgres
But restoring has to be done manually via psql -h localhost -p 54322 -U postgres -f dump.sql.
I updated Supabase - backup and restore is working
Supabase stops database for every 2 months?