@ewrw using sudo as openhab requires some additional work. Better make sure openhab has acces to all required folders by setting the right permission to those files. Additional openhab has no bash as default configuration, see below link for more information.
- try to fix the date problem. But your command filename command works as intended on my RPI. So maybe a problem when calling the zip command.
today=$(date '+%d-%m-%Y_at_%H:%M')
filename="/media/openhabbackup/OHbackup_${today}.zip"
My way to get openhab to execute external commands allways follows the same procedure.
- Try to execute your script as user openhab in the command line.
sudo -u openhab /etc/openhab2/scripts/backup.sh
When this does not work, you can’t proceed. Have a look here on how to solve it if you really need sudo.
After that also read back the return value and print it to the log.
var String cmdReturn = executeCommandLine=("sudo bash /etc/openhab2/scripts/backup.sh")
logInfo("Backup", "Result:" + cmdReturn )
Maybe you get some more info for a better understanding here .