Write to log within script before/after

I would like to write informations to the log file during the backup within the script used during before/after th bakcup

Is it possible ?
Thanks

Hi @phil welcome to the forum!

The scripts are executed and the operation will not continue until the scripts complete, so you would have to spawn a process for it to work.

But there is no communication with the script during the (backup) operation, so currently I do not see a way.

What kind of information would you like to log?

Topic title says “log”, but original post says “log file”. Do you specifically mean to the log-file option path?

If all else fails, there’s the file append operator >>, but I’m not sure if it’d go as desired or cause conflicts.

Sorry, i mean the log-file :

In the backup configuration, i defined the --log-filename and also the --log-file-log-level to Warning
But during the backup i would like to write extra informations in the log-file

What’s wrong with at least trying to use the append operator? You can even get the path in the script.
I’m not a batch file expert (and I don’t know if you are, or even if it’s Windows), but here’a an example:

echo one >> %DUPLICATI__log_file%
echo two >> %DUPLICATI__log_file%
(
echo three
) >> %DUPLICATI__log_file%
C:\tmp>type append_info.log
one
two
three
2024-05-31 06:20:48 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started
...

Nothing’s wrong. Thank you for your reply, it’s exactly what i needed.

1 Like