Skip to content

Instantly share code, notes, and snippets.

@prakhar-goel
Forked from nabucosound/heroku_env_copy.sh
Created September 11, 2017 12:24
Show Gist options
  • Save prakhar-goel/ace2fc073fc83ad40a9c55aabc4c7e80 to your computer and use it in GitHub Desktop.
Save prakhar-goel/ace2fc073fc83ad40a9c55aabc4c7e80 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"
defaultKeys=(DATABASE_URL PAPERTRAIL_API_TOKEN ROLLBAR_ACCESS_TOKEN ROLLBAR_ENDPOINT)
while read key value; do
key=${key%%:}
if [[ ${defaultKeys[*]} =~ $key ]];
then
echo "Ignoring $key=$value"
else
echo "Setting $key=$value"
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