Can you transfer heroic databases between applications using forking?

We have a production database, and we would like to take pictures regularly in our intermediate database.

I know how to do this with pgbackups, I was wondering if anyone knows how to do this with the new forok HerokuPostgres function.

+5
source share
2 answers

Yes, you can create a plug directly from one application database to another. To do this, get the value for your DATABASE_URL from the main application, and then use it in the following command:

heroku addons:add heroku-postgresql:ronin --fork postgres://username:password@ec2.../database --app yourstagingapp
+7
source

Adding Craig's answer, here is a script by freeformz that does all the work.

app=${1}
db_type=${2:-ronin}

old_db=`heroku config -a ${app}-staging | grep ^HEROKU_POSTGRESQL | cut -d : -f 1 | sed s/_URL//`
heroku addons:add heroku-postgresql:${db_type} --fork `heroku config -a ${app} | grep ^DATABASE_URL | cut -d : -f 2-5` -a ${app}-staging
new_db=`heroku config -a ${app}-staging | grep ^HEROKU_POSTGRESQL | grep -v ${old_db} | cut -d : -f 1 | sed s/_URL//`
heroku pg:wait -a ${app}-staging
heroku pg:promote ${new_db} -a ${app}-staging
#Remove the old db
if [ ! -z "${old_db}" ]l; then
  heroku addons:remove ${old_db} -a ${app}-staging --confirm ${app}-staging
fi
+3

All Articles