# Copying env vars between applications

**URL:** <https://forums.balena.io/t/copying-env-vars-between-applications/362>\
**Category:** Project help\
**Created:** [October 18, 2016, 11:05pm UTC](https://forums.balena.io/t/copying-env-vars-between-applications/362 "2016-10-18T23:05:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [October 18, 2016, 11:05pm UTC](https://forums.balena.io/t/copying-env-vars-between-applications/362/1 "2016-10-18T23:05:43Z")

</div>

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](http://docs.resin.io/tools/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: [https://github.com/resin-io-playground/resin-envmigrate](https://github.com/resin-io-playground/resin-envmigrate)

```bash
$./envmigrate.py --help
Usage: envmigrate.py [OPTIONS]

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

Options:
  -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 Resin.io 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!

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [December 8, 2016, 6:27pm UTC](https://forums.balena.io/t/copying-env-vars-between-applications/362/2 "2016-12-08T18:27:58Z")

</div>

Written up this script in a bit more detail, together with another one in the [resin.io](http://resin.io) blog: [Use the API, Luke](https://resin.io/blog/use-the-api-luke/)
