Duplicati on linux + powercli

I have following case: I deploy linux machine (Ubuntu 20.04) which is virtual machine in my vSphere environment. I installed Powershell + PowerCLI (Powershell module used to interact with vSphere environment) and Duplicati. I want to make backup disks which will be dynamically mounted before backup task start. I prepare script in Powershell and when I start it manually it works without any problem, but when I try to use this script as run-script-before it does not connect to my vCenter. I have no idea why.
I’m looking for help.
Best regards

Just to make sure I’m following: you installed Powershell, PowerCLI, and Duplicati on this Ubuntu 20.04 VM, or somewhere else?

When you run the script manually, are you using a different user account than whatever account Duplicati is running as?

Yes, you are right. Powershell, PowerCLI and Duplicati on Ubuntu. Duplicati works as service (in context of root account). Script have to be started as root (with sudo or su).
Since I published previous post I found solution for my problem. I created another script which contain following text:

su -l -c /path-to-my-powershell-script

and now it works correctly. I suppose that when Duplicati starts ‘before-backup-script’ it run it as root, but without loading profile and it seems, that powerCLI module needs user profile to be loaded to work properly…

1 Like

Glad you figured it out! Thanks for following up with your solution. Never know who it might help in the future.