Unique Identifier of running Backup in environment variables?

Hello,
I am looking for an unique identifier which can be used in scripts which are triggered in “run-script-before” and “run-script-after”.

My use case is the following:

  • a script which is triggered by “run-script-before” is creating a logging-record in a database indicating that a specific backup has been started, including the start time
  • another script which is triggered by “run-script-after” updates the record with the status of the backup and the end time

How can I tell the second script which record should be updated?

Thanks a lot!

Welcome to the forum @SKO

Some of this is OS-dependent and script language dependent, and there is better info on the Internet.
If your second script can read data from a file (or dot-source something in Linux style), that may work.
On Windows, PowerShell might be able to do that. I haven’t found any claims that a .bat script can…

Duplicati does have a feature that may help. You can change options by “before script” writing output:
Below, pre.bat is run before the backup, and set.bat is run after the backup, and picks up the variable:

C:\tmp>type pre.bat
echo --backup-name="backup #123"
C:\tmp>type set.bat
set > C:\tmp\set.txt
C:\tmp>findstr backup_name set.txt
DUPLICATI__backup_name=backup #123

C:\tmp>

Your Duplicati installation folder has two run-script-example files for .bat file and sh script use, or see

https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.bat

https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh

–backup-name

A display name that is attached to this backup. Can be used to identify the backup when sending mail or running scripts.

If you don’t want to mess with that one, you might be able to find a harmless option to be a conveyor.