Note: You need to have to Heroku PGBackup addon first heroku addons:add pgbackups
..
Creates the backup on heroku first:
heroku pgbackups:capture
Download it to local via curl:
curl -o latest.dump `heroku pgbackups:url`
Restore it:
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d mydbname latest.dump
Remove the dump:
rm latest.dump
Create your DB dump locally:
pg_dump -Fc --no-acl --no-owner -h localhost mydbname > mydb.dump
**Add PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" in .bash_profile if you encountered version does not match error when doing pg_dump **
Upload mydb.dump to your S3 or a remote FTP.
Note: remember to set permission for file uploaded to S3
Next, call Heroku to download the dump and then restore it:
heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump'
heroku pgbackups # To see a list of all backups
heroku pgbackups:destroy <BACKUP_ID>