Hi, I am using “run-script-after” - but the script is also running, when I abort backup, which I often do. I don’t want to run the script in such a case. Is there some kind of error levels or environment variables which I can use?
In a general sense, all the Duplicati options are exposed as environment variables prefixed with “DUPLICATI__” and, due to some some env. variables not allowing dahes, all dashes (-) replaced with underscores (_).
So if you’re running a DOS batch file you could get to your
--throttle-upload setting by using
There are also some special non-option vairables that are probably what you’re intersted in:
- DUPLICATI__EVENTNAME = when script was triggered such as “BEFORE” or “AFTER”
- DUPLICATI__OPERATIONNAME = operation, such as “Backup”, “Cleanup”, “Restore”, etc.
- DUPLICATI__RESULTFILE = path to file in which result data is stored
- DUPLICATI__REMOTEURL = “URL” target backend
- DUPLICATI__LOCALPATH = path to folders being backed up or restored
- DUPLICATI__PARSED_RESULT = run result such as “Unknown”, “Success”, “Warning”, “Error”, or “Fatal”
So in your case (and assuming a DOS batch file) I’m guessing your script should start with something along the lines of
if *%DUPLCATI__PARSED_RESULT%* NEQ *Success* goto :EOF (or something like that).
Hey thanks… Yes I am running a .cmd file on Win7. Will need to test later. %DUPLICATI__PARSED_RESULT% returned an empty string, maybe it’s %DUPLICATI–PARSED-RESULT% … or I’ll send the output of “set” to a file to see what actually exists. I hope the variables operate in a global scope…
All files only have the “” characters in them. I.e., all variables were empty in the script.
It does not work this way
DUPLICATI__PARSED_RESULT status variable was introduced in v188.8.131.52-184.108.40.206_canary.
If you’re in the Experimental or Beta update channel, you probably use a version number that’s below 220.127.116.11.
As a workaround, you can use a script similar to this one to pull the parsed result from the result file:
Ah, there is a file, yes I can use this… I’m loving doing cmd magic Yes I am on experimental.
Btw I think Duplicati UI should show more support as for this topic.
Is there a table of all the possible values these:
DUPLICATI__EVENTNAME= DUPLICATI__OPERATIONNAME= DUPLICATI__PARSED_RESULT=
I am looking at possibly writing a universal before/after script.
but because there’s no documented API to version-manage, the values could change.
Oof. I will have to think about which ones should be stable enough to risk it.
The good news for you is that Duplicati development is so low on staff that I’m not sure change is likely.
Still, values pulled from code aren’t a solid guarantee that code won’t change. I suppose this should be considered a user-visible thing (via scripting), and maybe the future developers will keep that in mind…
One problem with a few current OPERATIONNAME values is they don’t match the name from rest of UI however getting them to line up may be hard to do without breaking scripts expecting the current names.
As I am looking at the list of
OPERATIONNAME values and thinking about what a “universal script” might actually DO, so far it seems to me that the only ones which will be triggering specific action are
Restore. The others will probably just be treated as attributes to be reported on / logged.
I suspect those will always be there, and the names seem fine (so no temptation to “improve” name).
That’s reasonable, though I don’t want to overemphasize the chance of change, except that I strongly suspect any attempt at handling every current operation will someday find some new operation made.