New Feature: JSON backup report

Starting from version 1.2.0, there is an option Send report after completion on the Backup page, which will allow you to send a report to an http/https address after a backup is completed.

The default format for this report is:

{
  "computer": "mac-mini",
  "directory": "/Users/gchen/repository",
  "end_time": 1580837217,
  "new_chunk_size": 0,
  "new_chunks": 0,
  "new_file_chunk_size": 0,
  "new_file_chunks": 0,
  "new_file_size": 0,
  "new_files": 0,
  "new_metadata_chunk_size": 0,
  "new_metadata_chunks": 0,
  "result": "Error",
  "start_time": 1580837217,
  "storage": "local.storage",
  "storage_url": "/Users/gchen/storage",
  "total_chunk_size": 0,
  "total_chunks": 0,
  "total_file_chunk_size": 0,
  "total_file_chunks": 0,
  "total_file_size": 0,
  "total_files": 0,
  "total_metadata_chunk_size": 0,
  "total_metadata_chunks": 0,
  "upload_chunk_size": 0,
  "upload_file_chunk_size": 0,
  "upload_metadata_chunk_size": 0
}

These stats are extracted from the BACKUP_STATS logs in the backup log.

To customize the report format, create a file named report.tmpl under ~/.duplicacy-web, such as:

{
    "BackupResult": "{{.result}}",
    "BeginTime": {{.start_time}},
    "TotalFiles": {{.total_files}},
    "Storage": "{{.storage_url}}"
}

All tokens in the form of {{.<key>}} will be replaced be replaced by the corresponding value in the json file above. The final report based on that report.tmpl file will be:

{
    "BackupResult": "Error",
    "BeginTime": 1580837417,
    "TotalFiles": 0,
    "Storage": "/Users/gchen/storage"
}
10 Likes

Many thanks for adding this reporting feature as it means that I can push data into Paessler PRTG monitoring tool using the HTTP Push Data Advanced sensor to monitor the status of backups! :slightly_smiling_face:

The only issue I face is that it appears that the PRTG sensor is unable to import string based values such as the “.result” field.

Would there be a possbilty to extend the feature of Duplicacy to report numeric status values such as ‘0’ (Ok) and ‘1’ (Failed) as a further available field in the reporting template?

It would also be great if the reporting feature could be extended to the Duplicacy functions of “check” and “prunes”?

Many thanks!

You can actually customize any field/values using scriptable golang templates. For example, create a report.tmpl file like this:

{
    "result": {{if eq .result "Success"}} 0 {{else}} 1 {{end}}
}

And you will get this report when the backup succeeded:

{
    "result": 0
}
2 Likes

Many thanks for letting me know about the golang ability, the if statement you have provided works perfectly!

Would it be possible to extend the functionality of reports to include Checks and Prunes?

Not at this time. Maybe in the later release if more people want it.

I don’t get it. What do you mean send a http report? Do you mean a POST? How does one use this?

Hi!
This feature sends a report (POST) to a online service of your choice (there are several, for instance https://www.duplicati-monitoring.com and https://healthchecks.io/), who will use the reports (or absence of one within a time limit) to notify you that there is a problem with your backup.

Duplicacy can also send you a warning by mail, but what if Duplicacy or your backup computer fails? It would not be able to send to you.

So this use of 3rd party service model could catch more potential failures.

There is a discussion here about a similar strategy, but using a wrapper script and CLI, but after checking with duplicati-monitoring, @gchen has included this functionality in the web version!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.