Dump PostgreSQL on Heroku and Download to Local

Here is short snippet how to create dump postgresql database on heroku and download it to your local computer.
Within your root project directory, run these heroku commands.

$ heroku pg:backups capture          # Dump remote database.
$ heroku pg:backups public-url       # Get download url for your dumped database.
$ curl -o latest.dump <download_url> # Download your database.
# Restore database to local database.
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump

Reference: https://devcenter.heroku.com/articles/heroku-postgres-import-export

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.