Search code examples
postgresqlherokureplication

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?


Solution

  • 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