Search code examples
djangoherokuforemandjango-database

Replicate Production Django Database to Local Foreman Server


I would like to have a local copy of the data in the Django database to facilitate offline development. The production version is hosted by Heroku; the data is stored in a Postgres database and I am using foreman locally with the default mysqlite database.


Solution

  • This is easily done by exporting a backup from Heroku's pgbackup application, which can be done either through your dashboard or by going to your repo's root directory and running the following:

    $ heroku pg:backups capture   # to capture snapshot of current db
    $ curl -o latest.dump `heroku pg:backups public-url`
    

    You now have a Postgres dump file that can populate from an empty db on your local Postgres server. Most simply is to use PGAdmin and Load From Restore.

    More info here.