Only back up when on certain WiFi networks?

UI is only CLI wrapper so I am sure that you are doing something wrong. There must be some mix up.

Also because for me it works regardless. UI or CLI does not matter.

Can be very simple and obvious but hard to find:) Impossible to guess unfortunately.

Ok, I got it working… Hopefully this helps someone else.

# test on local backup.
kopia repository connect filesystem --path=/path/to/backup_storage --enable-actions
kopia policy set /path/to/source --before-snapshot-root-action ~/bin/kopia_network.sh --action-command-mode=essential
kopia snapshot create /path/to/source

The last command above fails if kopia_network.sh returns anything other than 0.

Once it works here, remove for the local backup if desired:

kopia policy list
kopia policy show /path/to/source
kopia policy set /path/to/source --before-snapshot-root-action "" 
kopia policy show /path/to/source
kopia repository disconnect

Per my LLM, kopia-UI needs to have enable-actions turned on, so set Exec=/opt/KopiaUI/kopia-ui --enable-actions %U in ~/.config/autostart/kopia-ui.desktop. This is on Debian. Other operating systems will be different.

Then, replicate the above on a remote SFTP backup destination.

KCONFIGFILE=~/.config/kopia/repository-foo.config

# I'm using SFTP with external SSH, but adjust this to your remote destination.
kopia repository connect sftp --config-file=${KCONFIGFILE} --path=/remote/folder/backup/dest --host=remote-hostname --username=user --external --log-level=debug --enable-actions  # this takes 10 minutes to build a cache. 

kopia repository status --log-level=debug --config-file ${KCONFIGFILE} # verify connected to correct repository

kopia policy show /path/to/source --log-level=debug --config-file ${KCONFIGFILE} # look for Actions

kopia policy set /path/to/source --log-level=debug --before-snapshot-root-action ~/bin/kopia_network.sh --action-command-mode=essential --config-file ${KCONFIGFILE}

kopia policy show /path/to/source --log-level=debug --config-file ${KCONFIGFILE} # look for Actions

kopia repository disconnect

Then, set exit 1as a test on ~/bin/kopia_network.sh, launch KopiaUI, take a snapshot, and it should fail. Set exit 0 and it should run.

Issues: This is done from the CLI. The backup script is not shown in the KopiaUI Snapshot Actions so changing this behavior requires CLI commands, not GUI commands.

Good you made it working.

Still this is strange. I have never done it. I only enable actions in config file as per docs:

When using KopiaUI, actions can be enabled globally by editing your repository.config (it is located in the Config File location in KopiaUI under Repository) and change "enableActions": false to "enableActions": true. Save the file and restart KopiaUI.

But probably it only means that there are many ways how to skin a cat. Not all documented properly.