How to export and import a database inside supabase #773
-
Hi, I would like to export a database I created in one project in supabase (scheme+data) and then import it into another project still in supabase. How can I achieve that? Is it possible? Great work by the way, the project is amazing 👍 |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 13 replies
-
You have the database connection string on Then:
The databases share some tables/schemas, so a full dump could fail. An option would be to |
Beta Was this translation helpful? Give feedback.
-
Extending this convo: Attempted a schema dump in command line and in pgAdmin based on the docs and then this discussion and got the following errors:
|
Beta Was this translation helpful? Give feedback.
-
I need to do this too. I know very little about SQL so what I did was go to Supabase SQL Editor on the web. Then, in the top section I wrote |
Beta Was this translation helpful? Give feedback.
-
the /settings/database is the menu path - you go there in your supabase admin console and copy the info... |
Beta Was this translation helpful? Give feedback.
-
Writing here in case it helps somebody else - I did a backup from a Heroku postgres and wanted to move it to Supabase. What worked for me was using PgAdmin.
|
Beta Was this translation helpful? Give feedback.
-
Why not adding a button in console to export json schema from a table (with child table) ? |
Beta Was this translation helpful? Give feedback.
-
Can't help thinking this is a completely obvious thing for supabase users to want to do, and that there should be an out of the box way of making such a copy. Perhaps some would not be permitted by data protection rules to make copy of data but, for most, the ability to work safely with a copy of production data is useful. Perhaps the assumption is that we are all postgres cli experts? But there's a javascript SDK which means the audience is broader than postgres folk |
Beta Was this translation helpful? Give feedback.
You have the database connection string on
/settings/database
, you copy it and then you can connect to your db from your terminal(psql <connection_string>
) or any other client.Then:
pg_dump <connection_string_from_db_1>
-> extract the dump ->pg_restore -d <connection_string_from_db_2> dump
The databases share some tables/schemas, so a full dump could fail. An option would be to
pg_dump
specific tables that you want and only restore them on the other database.