How to backup/restore standalone heroku postgres d

2019-04-10 23:23发布

问题:

Is there a Heroku way to backup / restore a standalone postgres database at https://postgres.heroku.com/ apart from using pg_dump / pg_restore ? The database is not attached to any app.

I can create a dump using

pg_dump --verbose -F c -b -h hostname -p port -U username -f "backup.dump" database_name

and restore it using

pg_restore --verbose --clean --no-acl --no-owner -h hostname -p port -U username -d database_name "backup.dump"

回答1:

Looks when you create a new database, heroku automatically creates an app for you. Check it with heroku list So you can restore using the empty app.

heroku pgbackups:restore DATABASE 'dumped-db-secure-url' --app heroku-postgres-xxx