Output from run scripts

Hello gentlewomen and gentlemen,

big thanks for this cool application. I have one problem I am not able to track down on my own currently:

I am using a pre-script that collects data to be backed up from various locations before the actual backup starts. This is stuff like dumping a MySQL database to files, cloning GitHub repos etc.

Every now and then the duplicati backup job issues some warnings like this:

    Warnings: [
        2020-05-03 17:15:27 +02 - [Warning-Duplicati.Library.Modules.Builtin.RunScript-StdErrorNotEmpty]: The script "C:\\MyPath\\duplicati_pre_post.cmd" reported error messages: Systemfehler 5 aufgetreten.

Zugriff verweigert

This is “System error 5 occured - Access denied”. So as the messages state this happens either in my pre or in my post script. But I have no idea which actual line or command in my script fails there.
My script prints quite some status log lines using a regular “echo” command so if I could just see the stdout (or also stderr) from my script then I could probably get an idea what is going on.
I could not reproduce the error yet running the script manually.

I tried several options like log-file, run-script-log-level, log-file-log-level. I configured a separate log file using “log-file” and also I looked into the sqlite-DB accossiated with my backup job. I still could not find any output of my pre-post-script.

So, please, is there a way to get the full ouput of the pre-post-scripts including stdout/stderror? Or is there another best practice on how to debug those scripts?

Welcome to the forum!

I made a post recently discussing how Duplicati handles stdout and stderr from the pre and post scripts. Basically stderr is included in the Duplicati logs, as you note above. But stdout is either ignored completely (in the post- script) or it is parsed in order to adjust backup job behavior (in the pre- script).

For debugging your script, probably the easiest thing to do is place this at the end of any line that may cause an error. It will redirect both stdout and stderr to a file:

1>> C:\Temp\debug.log 2>&1

So your pre/post script might end up looking like this:

@echo off

some-command  1>> C:\Temp\debug.log 2>&1
another-command  1>> C:\Temp\debug.log 2>&1

This way you can at least capture the output to help you figure out what’s going on.

Thanks for your answer and sorry for my late reply. Got distracted…

In the meantime I did something very similar to what you have proposed. In my case instead of modifying the log output in the script I inserted an intermediate script that calls the original script and pipes its whole output to a log file.

I renamed my script duplicati_pre_post.cmd to duplicati_pre_post_exec.cmd and created a new file duplicati_pre_post.cmd with this content:

duplicati_pre_post_exec.cmd > E:\duplicati_script_log.txt 2>&1
exit /B 0

Worked so far and I could spot by problem, thanks!

1 Like

Good to hear, thanks for following up!