Tuesday, June 19, 2012

Sync database from production db on Heroku

One could use the awesome taps gem like so:

heroku db:pull

However that gets real slow real quick so I had to use PG Backups addon instead

# Install heroku addon
heroku addons:add pgbackups

# Capture latest db snapshot on heroku
heroku pgbackups:capture

# Get download url and enter it in browser with a heroku login session
heroku pgbackups:url {latest_backup_name}

# Restore pg dump into local PostgreSQL database
pg_restore -d {db_name} ~/Downloads/{latest_backup_name}.dump

No comments: