Search code examples
postgresqlherokuheroku-postgres

Heroku download pg:backups how to


I know there are similar questions but the old Heroku's pg:backups addon has been deprecated.

So, following the new docs, I get a public URL that expires after ten minutes after this command:

heroku pg:backups public-url backupnumber --app appname

What do I do with the public-url? I can't find a comprehensible tutorial online that helps me download the dump file and populate a local database.

I'm using Ubuntu 14 and Postgresql. Thanks for your help.


Solution

  • You can use curl to download the backup using the public-url, e.g.

    curl -o appname.dump `heroku pg:backups public-url --app appname`
    

    Then you can use the Postgres pg_restore utility to restore the backup to your local database, e.g.:

    pg_restore --verbose --clean --no-acl --no-owner -h localhost -U appuser -d appname appname.dump
    

    (substitute your username for appuser and your database for appname).

    There is more detail at https://devcenter.heroku.com/articles/heroku-postgres-import-export