How to import a Heroku PG dump into local machine

前端 未结 5 950
小鲜肉
小鲜肉 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条回答
  •  [愿得一人]
    2020-12-04 13:24

    You see errors because psql tries to interpret SQL queries when you're actually giving him a compressed dump (that's what heroku uses).

    While you can't read the dump, pg_restore -O latest.dump gives you valid SQL you could pipe to psql but the easy solution is the following one :

    pg_restore -O -d app_development latest.dump
    

    Notes :

    • Use -O because you probably don't use the random username of your remote heroku postgres db.
    • Heroku doesn't recommend to use taps but I don't know how really risky it is.

提交回复
热议问题