Import Heroku Postgresql Database to Local Database

When you want to backup your application database on heroku, you can use "PG Backups" add-on.

heroku pgbackups

and you will see old saved database.

Select last one, example: b004

heroku pgbackups:url b004

and you will get an url, copy it

curl -o latest.dump "PASTE URL HERE"

you downloaded your dump.

and this code will restore your database (change 'MYUSER' and 'MYDB'):

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U MYUSER -d MYDB latest.dump

And you restored your postgresql local database.