I am using duplicati (latest stable|beta) with windows 10.
I want to set a
run-script-before-required to use a python script like:
--run-script-before-required="C:\Program Files\Python39\python.exe" C:\Users\thomas\Scripts\myscript.py
"C:\Program Files\Python39\python.exe" C:\Users\thomas\Scripts\myscript.py works fine in some shell (‘Command prompt’ (cmd), cygwin, …),
But duplicati says
Falscher Parameter (engl: ‘wrong parameter’):
I have tried to set the quotes different, but it always fails.
If I put the same statement in a batch-file (
myscript.bat) and use that batch-file for
--run-script-before-required, everything works fine.
Is it a bug or what am I doing wrong?
Thanks in advance
You can’t use command line parameters when specifying the script.
The usual workaround is to create a wrapper script. So change Duplicati to run a script like
C:\Users\thomas\Scripts\pre-backup.cmd (example) and then the contents of this cmd would be:
"C:\Program Files\Python39\python.exe" C:\Users\thomas\Scripts\myscript.py
Hope this helps.
I would like to return the exit-code of the script to duplicati. Is this possible with a cmd file?
Yes, in a batch (cmd) script you can use
exit n where n is the errorlevel.
If you want to use the errorlevel returned by the previous command (your python script), then I believe you can use:
That should work as long as python.exe will pass the error level of your python script back to the calling process (cmd).