Jan Cahlík
Jan Cahlík

Reputation: 151

How to pull data from my production supabase database into my local supabase database

I have been trying to fix this problem, I could not search any documentation for this specific problem. I have everyhing setup, the project is linked, the docker is running, I just can not figure out the way to pull data from my production database in supabase portal into my database in local environment

Any form of help is appreciated

Upvotes: 7

Views: 10007

Answers (2)

d9k
d9k

Reputation: 2074

Link your local database then

supabase db pull

supabase db dump --data-only > supabase/dump-data.sql

then run this sql on local database started with supabase start.

Usually it's localhost:54322, postgres db, postgres user, postgres password.

About another solution:

supabase db remote commit prints warning:

Command "commit" is deprecated, use "db pull" instead.

Consequent data dumps

...would sync records insertions but wouldn't sync records deletions.

To fix it clear target local tables before applying data dump.

For example you can achieve it with DBeaver x-platform database client.

Select tables to clear, right click, Tools -> Truncate, then on dialog window "Truncate table parameters" -> "Settings" -> check "\[v\] Cascade" -> \[Proceed\] button

Upvotes: 7

thorwebdev
thorwebdev

Reputation: 1152

You can use supabase db remote commit to capture any changes required for your local database to match the schema of your remote Supabase project.: https://supabase.com/docs/guides/cli/local-development#link-your-project

Upvotes: 0

Related Questions