Using heroku pg:pull to restore a backup to a macOS laptop

Today I worked out how to use the Heroku pg:pull command and to pull a Heroku backup to my laptop. is the easiest way I know to run a PostgreSQL server on macOS: just install using the installer, then click the "Initialize" button in the UI.


Assuming you have the Heroku CLI installed, the heroku pg:pull command can pull a Heroku database backup and load it into a local database. tells you that you need the following:

heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

The app name is your app name (whatever comes before

I found my all-caps environment variable by running the following:

heroku run env -a simonwillisonblog | grep POSTGRESQL
Running env on simonwillisonblog... up, run.2963 (Hobby)

Then I ran this command:

heroku pg:pull HEROKU_POSTGRESQL_OLIVE_URL simonwillisonblog -a simonwillisonblog

This created a local PostgreSQL database called simonwillisonblog and imported my latest backup.

Created 2020-07-10T17:16:13-07:00 · Edit