I’ve been using the reports feature for backups, trying to get something going that posts notifications to Discord. I was able to get the payload structure working, but I had a few requests since the formatting of certain variables is giving me issues. I’ve copied my payload and an example of the resulting notification at the bottom, if anyone is interested and wants to use/expand on it.
Seems golang templating is limited, is there a way to get the file sizes formatted into MB/GB/TB? This is already being calculated to some degree for the stats that are logged.
2020-10-10 00:17:44.454 INFO BACKUP_STATS Files: 1128007 total, 133,320M bytes; 37 new, 1,886M bytes
I also couldn’t find basic arithmetic functions for golang templating, so I was struggling to calculate time taken even though it would be {{.end_time}} - {{.start_time}}, then formatted into hours/minutes/seconds. Could it be possible to expose this variable natively? This is also already being logged in a reasonable format. It could also help to get endtime/starttime in UTC format so that they can be used for timestamps in Discord (Unix doesn’t work)
INFO BACKUP_STATS Total running time: 00:02:43
I also couldn’t find a variable for revision number, which is also appearing in the logs
BACKUP_END Backup for /backuproot at revision 15 completed
Finally, I hope we can get the opportunity to define report templates for copies, prunes, and checks, though copy is the most important one since that acts as an additional backup. I have a scheduled job that runs multiple iterations of each command, and being able to generate a report for the entire job would be ideal.
{
"username": "Duplicacy",
"avatar_url": "https://avatars3.githubusercontent.com/u/10550069?s=400&v=4",
"embeds": [
{
"author": {
"name": "Duplicacy",
"url": "https://duplicacy.com",
"icon_url": "https://avatars3.githubusercontent.com/u/10550069?s=400&v=4"
},
"title": "{{.computer}} {{.storage}} Backup: {{if eq .result "Success"}} :white_check_mark: {{else}} :x: {{end}}",
"url": "https://duplicacy.domain.com",
"color": {{if eq .result "Success"}} 4961603 {{else}} 13369344 {{end}},
"fields": [
{
"name": "New Files",
"value": "{{.new_files}}",
"inline": false
},
{
"name": "New File Size",
"value": "{{.new_file_size}}",
"inline": false
},
{
"name": "New Chunks",
"value": "{{.new_chunks}}",
"inline": false
},
{
"name": "New Chunk Size",
"value": "{{.new_chunk_size}}",
"inline": false
},
{
"name": "Total Files",
"value": "{{.total_files}}",
"inline": false
},
{
"name": "Total File Size",
"value": "{{.total_file_size}}",
"inline": false
},
{
"name": "Total Chunks",
"value": "{{.total_chunks}}",
"inline": false
},
{
"name": "Total Chunk Size",
"value": "{{.total_chunk_size}}",
"inline": false
}
]
}
]
}