Last active
August 16, 2022 11:16
-
-
Save anhkind/e4bcde6a7bbd9f080cd6 to your computer and use it in GitHub Desktop.
Heroku postgres: dump and restore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Details: https://devcenter.heroku.com/articles/heroku-postgres-import-export | |
# Create postgres role (v13) if not existing yet | |
createuser -s postgres -U <os-username> | |
# Dump | |
heroku pg:backups capture | |
curl -o latest.dump `heroku pg:backups public-url` | |
# Restore to local db | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d mydb latest.dump | |
# Restore to another DB on Heroku (DATABASE_URL represents the HEROKU_POSTGRESQL_COLOR_URL on the app-2) | |
heroku pg:backups restore `heroku pg:backups public-url -a app-1` DATABASE_URL -a app-2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment