I have a heroku database, d76mj7ltuqs
.
I then have a local database, test_development
.
The schema is the same on both of these databases - I want to pull all of the data from my production database and overwrite my local database, so that local is an exact replica of production at the time of pull.
How can I do that in Postgres?
If no --version flag is set, the upgrade will default to 14. Performing a pg:upgrade requires app downtime on the order of 30 minutes.
Use heroku's "pg:pull":
You'll need to clear your local DB:
rake db:drop
Then collect some information from Heroku:
heroku pg:pull DATABASE_URL test_development
This will connect to the heroku DB, and copy it to the local database.
See Heroku's documentation on pg:pull for more details.
clean your local database:
rake db:schema:load
dump your heroku database:
heroku pg:backups:capture -r <**your production git repo name**> heroku pg:backups:download -r <**your production git repo name**>
load data in your local database
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <**test database name**> latest.dump
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With