Skip to content

Instantly share code, notes, and snippets.

@cjavdev
Created July 5, 2021 19:45
Show Gist options
  • Save cjavdev/89db51298d02d62b71c4abd3ed6f04aa to your computer and use it in GitHub Desktop.
Save cjavdev/89db51298d02d62b71c4abd3ed6f04aa to your computer and use it in GitHub Desktop.
Quick and dirty clone heroku postgres db locally
#!/usr/bin/env bash
set -e
# Dump prod database into ./heroku.dump
curl `heroku pg:backups public-url` > heroku.dump
# Drop and recreate the local database
rails db:drop db:create
# Reload the data from ./heroku.dump into postgres
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d YOUR_DB_NAME ./heroku.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment