Skip to content

Instantly share code, notes, and snippets.

@timbophillips
Created February 21, 2021 13:03
Show Gist options
  • Save timbophillips/c6ee78d01b2680e4174faeb75280d764 to your computer and use it in GitHub Desktop.
Save timbophillips/c6ee78d01b2680e4174faeb75280d764 to your computer and use it in GitHub Desktop.
download / backup a Heroku cloud postgresql database to a *text* psql file
#!/bin/bash
HEROKU_APP_NAME=app-name
OUTPUT_SQL_FILENAME=~/Downloads/myDB.psql
heroku pg:backups:capture --app $HEROKU_APP_NAME
heroku pg:backups:download --app $HEROKU_APP_NAME
pg_restore ./latest.dump -f $OUTPUT_SQL_FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment