Batch script - environment variables ignored? (Win)

In an attempt to automate my backups using a batch script, I’m considering the usage of the Duplicati environment variables so I wrote the following batch script (Windows):

echo Init global environment variables
set TARGET_BASE=Z:\oracle
set DUPLICATI_EXE=D:\app\duplicati\Duplicati.CommandLine.exe

set BACKUP_NAME=app_adb
set SOURCE_DIR=D:\app\adb

echo Init DUPLICATI__ environment variables
set DUPLICATI__auto_cleanup=true
set DUPLICATI__auto_update=false
set DUPLICATI__auto_vacuum=true
set DUPLICATI__backup_name=%BACKUP_NAME%
set DUPLICATI__blocksize=200KB
set DUPLICATI__compression_extension_file=D:\app\duplicati\default_compressed_extensions.txt
set DUPLICATI__compression_module=zip
set DUPLICATI__console_log_level=Information
set DUPLICATI__dblock_size=256MB
set DUPLICATI__dbpath=D:\app\duplicati\local_db\%BACKUP_NAME%_db.sqlite
set DUPLICATI__disable_module=console-password-input
set DUPLICATI__encryption_module=aes
set DUPLICATI__exclude_empty_folders=false
set DUPLICATI__full_result=true
set DUPLICATI__log_file=%TARGET_BASE%\logs\duplicati-%BACKUP_NAME%.log
set DUPLICATI__log_file_log_level=Information
set DUPLICATI__log_retention=1095D
set DUPLICATI__retention_policy="2W:U,4W:1D,6M:1W,U:1M"
set DUPLICATI__tempdir=D:\app\duplicati\temp
set DUPLICATI__thread_priority=belownormal
set DUPLICATI__use_background_io_priority=true
set DUPLICATI__use_block_cache=true

echo Calling Duplicati
echo --
echo --
echo Backup created

As intended, I replaced all ‘-’ by underscored in the argument names yet it still appears that Duplicati is ignoring them all together. Even the DUPLICATI__dbpath does not seem to be used.

Is this suppose to work this way or did I misunderstood how these env variables can work?

Hello and welcome!

I could be wrong but I think those DUPLICATI__* variables are read only. They are set by Duplicati so your scripts can reference them, but you can’t change the values directly.

There is a special case where you can adjust Duplicati parameters in a --run-script-before script, but that is done by echoing new config options to STDOUT, not by modifying the environment variables:

I think for your use case you are better off using normal Duplicati command line options, which could incorporate environment variables if desired.

Alternatively, if you want the ability to run jobs via command line but still want to keep the GUI for monitoring/configuration, you could look at duplicati-client. This lets you trigger web GUI jobs manually. All job config data is stored in the web UI server so you don’t need to pass any command line options at all.

Thanks a lot for pointing that out, and yes on second look at it you are correct indeed. Those environment variables are set by Duplicati for usage in pre/post scripts.