Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Heroku pgbackups:restore rebuild the database or just repopulate it?

I'm trying to copy my production database on Heroku across to my staging server.

My staging server has been ahead of my production server with a migration that creates an extra table. I now want to dry-run the migration to add that table on the production database and so would like to revert my staging's database in order to do so.

The problem is that each time I restore the staging database to the production one the table sticks around. I was expecting the database to be destroyed and repopulated but it only seems to be being repopulated.

heroku pgbackups:url b104 --app production
# 'http://s3.amazonaws.com/...'

heroku pgbackups:restore DATABASE 'http://s3.amazonaws.com/...' --app staging

Every time I do this I find that the "newer" table is still remaining.

Does pgbackups:restore actually restore table structure or simply data - what's going on here?

like image 654
Peter Nixey Avatar asked Feb 05 '12 19:02

Peter Nixey


People also ask

How do I restore a Heroku database backup?

As per Heroku's docs: In order for PG Backups to access and import your dump file you will need to upload it somewhere with an HTTP-accessible URL. Keep in mind the URL should be a downloadable link as in the mentioned question.

Where are heroku backups stored?

Snapshots are stored directly in AWS's S3 object store. Base backups and WAL files are pushed to' S3 through an application called WAL-E as soon as they are made available by Postgres. All databases managed by Heroku Postgres provide continuous protection by persisting snapshots, base backups and WAL files to S3.


1 Answers

A restore is a simple Postgres restore, so essentially a scripted version of your data.

In order to do this, you need to nuke your database first, and then rebuild it from the database script:

heroku pg:reset
heroku pgbackups:restore blah...
like image 189
Neil Middleton Avatar answered Oct 23 '22 12:10

Neil Middleton