Backup and restore your supabase DB
using pg_dump and psql
If you need to backup your supabase database locally, you can use the pg dump tool:
First install it from Postgres:
Once installed, you need to setup your PATH
search for “environment variables” in system properties:
Click on environment variables and search for “Path” and then click edit:
Now add a new path:
The path will usually be something like C:\Program Files\PostgreSQL\17\bin
where 17 is the version of PostgreSQL that you just installed.
Click ok, apply and reboot you pc.
next go into Supabase and in your database click on the “connect” button at the top:
now go into ORMS and find the “direct” path to your database:
copy this URL, e.g.
“postgresql://postgres.fkrmydhxikfhccdvyfaj:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:5432/postgres”
next open up a command prompt in windows as administrator, and type in:
pg_dump — version
this will confirm pg_dump is installed correctly, and PATH was also setup correctly.
Backup the DB
taking the URL you just copied from ORM’s, use the following command, remembering of course to replace with your database password:
pg_dump --dbname="postgresql://postgres.fkrmydhxikfhccdvyfaj:[your db password without the square brackets]@aws-0-us-east-1.pooler.supabase.com:5432/postgres" --disable-triggers > database-dump.sql
if you can’t remember your password, you’ll have to reset it:
If all goes well, it will dump the db onto your local machine.
Restoring the DB
If you want to restore your DB , either to the same Supabase DB or to another, then use the following command to restore, all whilst using the details of your NEW supabase DB (retrieved from the ORM’s section)
For example:
psql --dbname="postgresql://postgres.tumibfmcgujdgckycnva:[supabase password]@aws-0-us-east-1.pooler.supabase.com:5432/postgres" -f database-dump.sql
Once again if you don’t know your new DB password details, then first of all go into Project Settings -> database and just change it…. perhaps even to the same password as your old DB that you backed up.
This is really useful if you use things like bolt.new and need to spin up a new project but want to keep the automation element of bolt applying migrations to your DB, which it will only do for new databases. So in this case, let it fire up a new database for you (which it can write to) and then just restore your database to this one.