How-to: heartbeat monitoring with start, success and failure pings (tested on 2.4.1.0)

I’m the founder of Watchgoose (cron and heartbeat monitoring), so I have an interest here.

People have asked here how to report Duplicati results to a ping-URL service, so here is what I tested on Duplicati 2.4.1.0 (CLI, Docker image, local destination). The same ideas work with any service that has start, success and fail URLs.

The catch with --send-http-url alone

Duplicati sends one report after each run, to the same URL, whatever the result. If you point it at a plain ping URL, a failed backup is recorded as a successful ping. I confirmed this with three different Fatal errors.

Option 1: before/after scripts (start, success and fail)

/usr/local/bin/watchgoose-start.sh:

#!/bin/sh
curl -fsS -m 10 --retry 3 -o /dev/null "https://watchgoose.com/ping/your-check-uuid/start"
exit 0

/usr/local/bin/watchgoose-end.sh:

#!/bin/sh
URL="https://watchgoose.com/ping/your-check-uuid"
case "$DUPLICATI__PARSED_RESULT" in
  Success|Warning) ;;
  *) URL="$URL/fail" ;;
esac
# Send the result summary as the ping body (Watchgoose keeps the first 10,000 bytes).
tail -c 10000 "$DUPLICATI__RESULTFILE" 2>/dev/null \
  | curl -fsS -m 10 --retry 3 -o /dev/null --data-binary @- "$URL"
exit 0

Make both executable and add these advanced options to the backup job:

--run-script-before=/usr/local/bin/watchgoose-start.sh
--run-script-after=/usr/local/bin/watchgoose-end.sh

Results:

  • Successful backup: start, then success with the result summary.
  • Missing source folder, or a database out of sync with the destination: start, then fail, with “Failed: …” and the error in the body.
  • Warnings (for example one unreadable file) count as success here. Remove |Warning from the script if you want them to alert.
  • Duplicati never starting: nothing arrives, and the check alerts when overdue.

The scripts always exit 0, because a non-zero exit from a before script can change what Duplicati does.

Option 2: no scripts, JSON report plus keyword filtering

--send-http-url=https://watchgoose.com/ping/your-check-uuid
--send-http-result-output-format=Json

Then, in the check’s Filtering Rules, enable “Request body of HTTP requests” and set:

  • Success keywords: "ParsedResult":"Success","ParsedResult":"Warning"
  • Failure keywords: "ParsedResult":"Error","ParsedResult":"Fatal"

Keep --send-http-level at its default (all). In my tests the overall result appeared about 650 bytes into the JSON, so it falls within the 10,000 bytes Watchgoose stores. This option has no start ping, so long-running backups aren’t timed.

Details, in case they help with other services

  • The default report format is a form-encoded POST (message=...). JSON is easier to read in a ping log.
  • Duplicati retries 3 times with a 1s delay (--send-http-retries, --send-http-retry-delay).

Watchgoose has a support plan for Open Source maintainers (Open Source Program - Watchgoose). I am happy to answer any questions.

Cheers!

Thanks to Kenneth prompt handling of the subject a simpler way is now in the official docs and it needs no scripts on Duplicati 2.4.0.0 and later: Sending live status reports, Heartbeat monitoring.

--http-report-status-url posts a JSON report when an operation starts, at intervals while it runs, and when it finishes. Point it straight at the check’s ping URL:

--http-report-status-url=https://watchgoose.com/ping/your-check-uuid

Then let the check classify each report by its body. In Watchgoose that is under Filtering Rules… on the check’s page:

  • Tick Request body of HTTP requests
  • Start keywords: "status":"Started"
  • Success keywords: "status":"Completed"
  • Failure keywords: "status":"Failed","errorMessage"
  • If no keywords match: Ignore the ping (this drops the progress reports)

The failure keywords are checked before success keywords so a run that completes with errors (it reports Completed together with an errorMessage) still counts as a failure. A run with warnings alone counts as a success, the same as in Option 1.

I tested it on 2.4.1.0 with a clean backup, backup with an unreadable file (Warning), missing source folder (Fatal) and a wrong passphrase (Fatal): start then success for the first two, start then fail for the other two. The “completed with errors” case I only checked in the source. Option 1 above is still the way to go with for users on versions before today’s 2.4.0.0.

Cheers!