Is there anyone, who tried to use duplicati with mychecks?
All I want to do is to make my duplicati job status reported on mychecks. Basically duplicati have to send a http request after doing the backup job depending of its result, for example:
when job passes: http://mychecks.example/check_id....
when it fails.
I was reading some docu and want to try executing –run-script-after. Is it a good way or is there some better?
I don’t know. Is it really something wrong with it?
I was expecting some hints, because it’s really hard to understand the docu. Let’s have a very first - –run-script-after. Description - “HTTP report url.”. Nice, but what it really does? What is report? How do I know what the job exit code is and how to use it to send proper http request?
All I need is to request http://mychecks.example/check_id....
accordingly with job’s exit code. That’s it.
Duplicati Notifcation forum topic has some of the same information that I’m posting now. Example Scripts covers DUPLICATI__PARSED_RESULT as used in linked example script.
There are probably some other script variables that you would want to use for the need.
The example script covers this if you use bash. If this is Windows, you can translate that.
Although you might not need it for your simple two-URL-no-report approach, it’s set using Reporting options in the User Manual, and is very flexible but possibly also not necessary.
Pinging API seems to allow HTTP POST if you want to put in some additional information.
I don’t know if you ever send reports by email, but I think the HTTP report is rather similar.
Below is a third-party Duplicati-specific option that had an outage and healthchecks.io talk:
I have no script to give, but there are some hints. I collected healthchecks topics via forum search box.
If mychecks is healthchecks, great. If not, some of the ideas might apply, or you can cover differences.
So I’ve prepared scripts for executing before and after the job using issues/4220. It’s a quite good way to send the status to healthchecks. My tries showed the issue is that script has to be hardcoded with UID value, so preparing and having separate scripts (actually 2 of them, for before and after) for each duplicati’s job will be painful.
What I’ve tried so far is to have universal script with 1 positional argument (for UID) and execute it from duplicati like “before.sh 1234-5678-abc”. Doesn’t work, because duplicat can’t find this file (just because of positional argument, it works without it).
The best way would be to have these 2 scripts universal (without any hardoced vaules inside). So I wanted to ask you about:
Is there way to pass somehow UID to the script with duplicati GUI?
Is it possible to set my custom variable and set it as environment variable with duplicati GUI? So the scripts could easily read it.
Is there some advanced option in duplicati GUI that could be used for passing the UID value? I was looking at them by the name and found parameters-file, but I’m not sure it could help.
Unless there is a conflict, you can probably get before script to save UUID for after to read.
That still means script for every job. Are jobs all on one system, or spread across various?
The parameters-file option only works on the commandline. GUI uses server database.
Duplicati gives you lots of environment variables. Can’t script map, say, job name to UUID? DUPLICATI__backup_name would be job name, and Linux probably has host info if needed.
If you want some ideas, just have the script write environment variables to a file, for a study.
DUPLICATI__REMOTEURL could also be used. Typically the folder is unique for every backup.
For this or the job name, I suppose you could put the UUID in the string, instead of mapping.
which rules out putting maps in the script. You can decide which is tidier, but in addition to extracting the UUID from variables like job names or destinations, you could pass it in any option that isn’t being used, such as Reporting options strings that aren’t used because you’re doing the reporting in a different way.
Not exactly meeting the universal script rule, but avoiding parallel-maintaining multiple scripts that could eventually get rather complicated if you get ambitious is to put most of the processing into another script which is called from a trivial first script that exists just to pass UUID in. Or you can use links and use $0.
Good job, that is a nice guide. I hope it will help others to simplify the setup.
I see a few things that can be improved:
REM Eventname is BEFORE if invoked as --run-script-before, and AFTER if
REM invoked as --run-script-after. This value cannot be changed by writing
REM it back!
REM Operation name can be any of the operations that Duplicati supports. For
REM example it can be "Backup", "Cleanup", "Restore", or "DeleteAllButN".
REM This value cannot be changed by writing it back!
You can use the event name to combine both scripts into a single one, that works before and after. That might be more convenient.
Also, in the past some people with scripts ran into issues, because they will also run for restore operations. So I would recommend to check the operation for backup, if that is not wanted.