Skip to content

Instantly share code, notes, and snippets.

@czj
Created November 21, 2012 10:17
Show Gist options
  • Save czj/4124118 to your computer and use it in GitHub Desktop.
Save czj/4124118 to your computer and use it in GitHub Desktop.
Transfert Heroku production db to local dev db
#!/bin/bash
# Get to the Rails app's root directory
cd `dirname $0`/..
APP_DIRECTORY=`pwd`
APP_NAME=`basename $APP_DIRECTORY`
# How-to:
# http://www.ryandaigle.com/a/pgtransfer-is-the-new-taps
if heroku plugins | grep -q "heroku-pg-transfer"
then
echo "Heroku PG transfer plugin already installed."
else
echo "Installing Heroku PG transfer plugin."
heroku plugins:install https://github.com/ddollar/heroku-pg-transfer
fi
# Transfert remote production database to local development database
heroku pg:transfer --to "postgres://localhost/${APP_NAME}_development" --confirm "$APP_NAME"
# App's link to postgres is corrupteda after database has been re-created
# Restart it via pow's / passenger's shortcut
touch tmp/restart.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment