Restore stack env file

Sometimes we accidentally remove items from our environmental variables section and need to restore them.

You will need backups BEFORE following this

If you do not have backups, you may be out of luck!

For backup software, I personally use Borg UIarrow-up-right for file level backups and PBS for entire VMs - I may write a guide for it in the future, but the software is constantly changing at the moment.

Veeam B&R is free for 7 machines in a homelabarrow-up-right which is a great product to have on your resume.

Get the stack ID

  1. Log into your Portainer instance and navigate to the relevant stack

  2. Have a look at the URL - you are looking for the ID - I have highlighted in bold below http://portainer.yourdomain.com/#!/2/docker/stacks/crowdsec-unifi?id=867&type=2&regular=true&orphaned=false&orphanedRunning=false

Get the volume path

  1. Log into your Portainer instance

    1. If you have multiple hosts, select the host running Portainer

  2. Select Containers

  3. Locate Portainer in the list and open it

  4. Scroll down to Volumes and locate the /data volume

  5. If it is direct mount (host/path is grey), copy the path Skip the rest of this section

  6. If it is a docker volume (host/path is a link), click on the volume name

  7. Copy the mount path

File to restore

The file to restore will be your mount path will be MOUNTPATH/compose/STACKID/stack.env

Some examples,

Last updated