I (still) use Portainer for maintain a couple of applications that don't support Kubernetes yet. One of those needed to be updated and I had setup the app as a stack, pulling docker-compose.yml from a privately hosted git repository. Now while initially setting up the stack I added environment variables using GUI instead of using stack.env file.

I made the mistake of assuming that Portainer will retain the environment values when destroying and re-creating the stack. I say mistake, because recently I realized that it isn't the case. And so, I had to resort to using backup of Portainer to extract values of environment variables out of it.

Portainer uses BoltDB, an embedded key/value database and the database file called portainer.db is located in /data directory. As long as you have a backup of that file, reading/extracting data from it should be fairly simple. Here's what I ended up doing,

  1. Retrieve database file portainer.db from backup.
  2. Run golang docker container docker run -it -v ~/backup-dir-containing-portainer.db-file:/mnt/portainer --rm golang
  3. Install boltbrowser go package within docker container go install github.com/br0xen/boltbrowser@latest
  4. Run the package boltbrowser -ro /mnt/portainer/portainer.db

This will open the database within terminal window. Navigate to whatever aspect of application config you want to browse, in my case, I was interested in retrieving environment values for one of the stacks.

Here's a screenshot of how it looks.

BoltDB_Browser