Copying env vars between applications


Recently on support we’ve been asked whether there’s an easy way to migrate environment variables between apps (e.g. when moving an app from one hardware architecture to another), without manually copy-pasting. The original question mentioned having 68 environment variables, so it was pretty important to automate.

The API and SDK can easily work with environment variables, so created a little helper script around the Python SDK, to take an input app, and output app, and optionally a delete env vars from the output that weren’t in the input originally.

Here’s the script, any feedback is appreciated:

$./ --help
Usage: [OPTIONS]

  Migrate environment variables from one app to another, optionally
  removing variables from the target that do not exist at the origin.

  -f, --from INTEGER  ID of application to copy env vars from  [required]
  -t, --to INTEGER    ID of application to copy env vars to  [required]
  --token TEXT auth token, can specify it with the RESIN_TOKEN
                      env var as well  [required]
  --delete-extra      Toggles deleting extra environment variables in the
                      receiving app
  -q, --quiet         Toggles hiding process details
  --yes               Confirm the action without prompting.
  --help              Show this message and exit.

Could also expand it to copy env vars between devices (or other combos like app->device or device->app), will check that out in the future.

In the meantime, any feedback is appreciated!

Ability to copy environment variables from one application/device to another

Written up this script in a bit more detail, together with another one in the blog: Use the API, Luke