Skip to content

Instantly share code, notes, and snippets.

@alexanmtz
Forked from nabucosound/heroku_env_copy.sh
Created August 1, 2018 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanmtz/4d2864aff253401bb2f7ce1167804100 to your computer and use it in GitHub Desktop.
Save alexanmtz/4d2864aff253401bb2f7ce1167804100 to your computer and use it in GitHub Desktop.
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
key=${key%%:}
echo "Setting $key=$value"
if [ "$key" != "DATABASE_URL" ]
then
heroku config:set "$key=$value" --app "$targetApp"
fi
done < <(heroku config --app "$sourceApp" | sed -e '1d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment