How to import a Heroku PG dump into local machine

前端 未结 5 956
小鲜肉
小鲜肉 2020-12-04 12:25

I\'m trying to import my production Heroku database into my development machine.

My local db is PostgreSQL.

First, I\'m exporting the dump from Heroku to my

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 13:08

    Follow these 4 simple steps in your terminal
    (Heroku Dev Center):

    1. Create a backup copy of your database:

      $ heroku pg:backups capture DATABASE_NAME
      
    2. Download the copy from Heroku (to your local machine) using curl:

      $ curl -o latest.dump `heroku pg:backups public-url`
      
    3. Load it*:

      $ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U YOUR_USERNAME -d DATABASE_NAME latest.dump
      
      • get YOUR_USERNAME and choose the desired database from your config/database.yml file.
      • DATABASE_NAME can be your development/test/production db (Ex. mydb_development)

    That's it!

提交回复
热议问题