Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1iraxa/008ffbb804a7319d875f93833e7148ce to your computer and use it in GitHub Desktop.
Save a1iraxa/008ffbb804a7319d875f93833e7148ce to your computer and use it in GitHub Desktop.
Heroku pg_dump
You could just make your own pg_dump directly from your Heroku database.
First, get your postgres string using `heroku config:get DATABASE_URL`.
Look for the Heroku Postgres url (example: `HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8@ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398`), which format is `postgres://<username>:<password>@<host_name>:<port>/<dbname>`.
Next, run this on your command line:
pg_dump --host=<host_name> --port=<port> --username=<username> --password --dbname=<dbname> > output.sql
The terminal will ask for your password then run it and dump it into output.sql.
Then import it:
psql -d my_local_database -f output.sql
https://stackoverflow.com/a/22896985/4148220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment