Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my staging and production have the same data? (Heroku)

I've looked at Heroku's Taps project (http://devcenter.heroku.com/articles/taps) but there's a huge constraint on foreign keys, so I'm uncomfortable with using this.

All I want to do is get my production data safely and put it on my staging app so the two are more closely matched. Advice?

like image 337
dmonopoly Avatar asked Aug 03 '11 17:08

dmonopoly


People also ask

Can I edit my website after publishing on Heroku?

If your project is deployed on Heroku Cloud Platform, you can easily make your changes using the CLI and deploy them to Heroku.

Is Heroku good for production?

Heroku provides a great developer experience where your Git repository is your source of truth. Additionally, with Heroku, developers choose to build their apps in any language of their choice. They can speed up development with the help of Heroku add-ons. Some of the add-ons are free, while others are paid ones.

Can multiple Heroku applications connect to a single database?

Attach the database as an add-on to other Heroku apps If you are connecting to a database from other Heroku apps, you can now attach a database add-on directly to multiple applications. This ensures that any changes to the database's URL will automatically propagate to your other apps.


2 Answers

Thoughtbot posted this a few weeks ago:

You need the pgbackups addon (free), and use this to transfer from production to staging

heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote production
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging

Gist here: https://gist.github.com/1095522

Edit: Make sure you have your git branches "staging" and "production" pointing to the heroku apps.

git remote add production production_heroku_app
git remote add staging staging_heroku_app
like image 114
Hock Avatar answered Oct 18 '22 03:10

Hock


If your staging app is using Postgre SQL as well, you can export your data as a backup using pgbackup (http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup) and then just copy it into your db folder. If not, you may have to use a conversion tool.

like image 45
Thariq Shihipar Avatar answered Oct 18 '22 05:10

Thariq Shihipar