cli icon indicating copy to clipboard operation
cli copied to clipboard

supabase start/stop no longer restores development database

Open brettatoms opened this issue 3 years ago • 1 comments

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:

  1. Run supabase start
  2. Make changes to the database
  3. Run supabase stop
  4. Run supabase start
  5. 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.

brettatoms avatar Jan 23 '22 13:01 brettatoms

Any updates on this?

zebaroni avatar Jun 12 '22 14:06 zebaroni

:tada: This issue has been resolved in version 1.8.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Oct 14 '22 03:10 github-actions[bot]

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.

sweatybridge avatar Oct 14 '22 03:10 sweatybridge

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.

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.

nexbotai avatar Apr 21 '23 22:04 nexbotai

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"
    }
]

sweatybridge avatar Apr 22 '23 03:04 sweatybridge

-- backup is not working. I have to import my data every time. What should I try?

mellowcello77 avatar May 01 '23 11:05 mellowcello77

no more saved in supabase/.branches/main/dump.sql ?

alemscoder avatar May 12 '23 05:05 alemscoder

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.

sweatybridge avatar May 12 '23 08:05 sweatybridge

I updated Supabase - backup and restore is working

mellowcello77 avatar Jun 08 '23 12:06 mellowcello77

Supabase stops database for every 2 months?

matek075 avatar Aug 16 '23 14:08 matek075