Please refer to previous article to understand the names we are using in this article.
heroku pg:backups:capture -a wheel-staging
heroku pg:backups:download -a wheel-staging
It will download a file called latest.dump
.
pg_restore --verbose --clean --no-owner --no-privileges --dbname=wheel_development latest.dump
In the above case replace wheel_development
with the name of the database you have.
You might get error something siimilar to as shown below.
pg_restore: [archiver] unsupported version (1.13) in file header
It probably means that the version of pg_dump
used by heroku is not as the version we are running locally.
First let's check the version running in heroku.
> heroku run bash -a wheel-staging
> pg_dump --version
pg_dump (PostgreSQL) 10.3 (Ubuntu 10.3-1.pgdg14.04+1)
It seems heroku is using version 10.3.
Now let's check our local version of pg_restore
.
> pg_restore --version
pg_restore (PostgreSQL) 10.0
As we can see that heroku used pg_dump
version "10.3".
Our pg_restore
version is "10.0"
Time to upgrade postgresql. Execute brew upgrade postgresql
.