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 UI 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 homelab which is a great product to have on your resume.
Get the stack ID
Log into your Portainer instance and navigate to the relevant stack
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®ular=true&orphaned=false&orphanedRunning=false
Get the volume path
Log into your Portainer instance
If you have multiple hosts, select the host running Portainer
Select Containers
Locate Portainer in the list and open it
Scroll down to Volumes and locate the /data volume
If it is direct mount (host/path is grey), copy the path Skip the rest of this section
If it is a docker volume (host/path is a link), click on the volume name
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