Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have a Heroku Postgres DB replicate down to a slave DB on my laptop?

I'd like to have my master Postgres DB, which is is hosted on Heroku, replicate down to a slave DB on my laptop. Is this possible?

Heroku's documentation talks about both master and slave hosted within Heroku: https://devcenter.heroku.com/articles/heroku-postgres-follower-databases

Someone else asked whether it's possible to have the master outside Heroku and a slave inside Heroku (it's not): Follow external database from Heroku

I haven't seen an answer for the reverse -- having the master in Heroku and the slave outside.

Why do I want this? To speed up development. With my app running locally and the DB in the cloud, the round-trip is long so data access is slow. Most data access is read-only. If I could have a local slave, it would speed things up significantly.

Related: what if my laptop is disconnected for a while? Would that cause problems for the master?

like image 761
Shahaf Avatar asked Feb 11 '13 19:02

Shahaf


2 Answers

You cannot make a follower (slave) outside of the Heroku network – followers need superuser access to create, which Heroku Postgres doesn't provide you, so you are limited to running a follower on Heroku.

If you want to pull down a copy locally for use/inspection, you can do so with pgbackups: https://devcenter.heroku.com/articles/heroku-postgres-import-export

like image 88
catsby Avatar answered Sep 23 '22 10:09

catsby


I'd highly recommend the program Parity for this.

It copies down the last Heroku backup to your local machine with a nice command line interface:

development restore production

like image 36
bswinnerton Avatar answered Sep 23 '22 10:09

bswinnerton