Skip to content

Instantly share code, notes, and snippets.

@cgrusden
Forked from nabucosound/heroku_env_copy.sh
Last active November 18, 2020 16:59
Show Gist options
  • Save cgrusden/bacf35581c151a3142d683ebac09d4b8 to your computer and use it in GitHub Desktop.
Save cgrusden/bacf35581c151a3142d683ebac09d4b8 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/
# TODO: Create list of ENV vars to send all at once instead of setting and restarting server after each
# update
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
key=${key%%:}
echo "Setting $key=$value"
heroku config:set "$key=$value" --app "$targetApp"
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