HandyGuySoftware / dupReport

Email summary reporting tool for use with Duplicati backup system
MIT License
77 stars 9 forks source link

Indicate Warning or Error in subject line of the mail report #172

Closed wechsler42 closed 3 years ago

wechsler42 commented 3 years ago

Hi there, I would like to make a feature suggestion. If one ore more Duplicati backup sets within the mail report yields a Warning or an Error please indicate it in the subject line of the mail report like this:

Thanks for offering DupReport!

HandyGuySoftware commented 3 years ago

Sounds like a great idea! Let me see ow best to incorporate it into the program.

HandyGuySoftware commented 3 years ago

I made some changes to the code that I think will address this and uploaded it to the Issue_172 branch. The change allows you to put keywords in the title= specification in the [report] section of the .rc file. Explanation can be found in the docs for that branch under "Reporting->The [report] section->Title Keyword Substitution." Please download that code and try it out and let me know what you think. I'm still doing some testing here so let me know if this addresses your suggestion. Thanks for taking a look.

HG

HandyGuySoftware commented 3 years ago

@wechsler42 , never mind, it's not working right. Let me play with it some more and I'll let you know when it's working.

HandyGuySoftware commented 3 years ago

@wechsler42 , I think I have it working now. Download the latest code from the Issue_172 branch and see if it works for you.

wechsler42 commented 3 years ago

Hi there, thanks for considering my feature suggestion. I tried the Issue_172 branch for test runs with 1 Warning and 2 Errors on my GMX mail account. However, it did not work at all for me. Whatever I tried: title = #ERROR# Duplicati Backup Summary Report title = Duplicati Backup Summary Report #ERROR# title = #ERROR##Warning# Duplicati Backup Summary Report title = Duplicati Backup Summary Report #ERROR##Warning# title = #ERROR##Warning# Except of the last trial I always received "Duplicati Backup Summary Report" as subject line. For the last trial I even got an empty subject line. Perhaps you have a hint for me what I could try more?

HandyGuySoftware commented 3 years ago

Hmmmm, that's not good.

The first thing that comes to mind is that the keywords must be in all caps. So #ERROR# should have worked but #Warning# would not.

I added some debugging statements into the code (which I should have done earlier) and uploaded a new version to Issue_172. Please download and run this new code using the -v7 option for each of the following:

title = #ERROR##WARNING# Duplicati Backup Summary Report title = Duplicati Backup Summary Report #ERROR##WARNING#

Then upload the resulting log files (all sensitive information will be masked in the log file). Also please post the [report] section from your .rc file so I can see if there may be a problem with the specification.

Thanks.

wechsler42 commented 3 years ago

Hi there, thanks for the guidance.

I run the trial for case: title = #ERROR##WARNING# Duplicati Backup Summary Report with this command: ./dupReport.py -i -v7 and this report section in my .rc file: [report] layout = srcdest, noactivity, lastseen columns = source:Source, destination:Destination, date:Date, time:Time, duration:Duration, dupversion:Version, examinedFiles:Files, examinedFilesDelta:+/-, sizeOfExaminedFiles:Size, fileSizeDelta:+/-, addedFiles:Added, deletedFiles:Deleted, modifiedFiles:Modified, filesWithError:File Errors, parsedResult:Result, messages:Messages, warnings:Warnings, errors:Errors, logdata:Log Data title = #ERROR##WARNING# Duplicati Backup Summary Report titlebg = #FFFFFF border = 1 padding = 5 sizedisplay = mb repeatcolumntitles = true suppresscolumntitles = false durationzeroes = true displaymessages = false jobmessagebg = #FFFFFF displaywarnings = true jobwarningbg = #FFFF00 displayerrors = true joberrorbg = #FF0000 displaylogdata = true truncatemessage = 0 truncatewarning = 0 truncateerror = 0 truncatelogdata = 0 joblogdatabg = #FF0000 nobackupwarn = 0 nbwsubject = Backup Warning: #SOURCE##DELIMITER##DESTINATION# Backup Not Seen for #DAYS# Days groupheadingbg = #D3D3D3 normaldays = 5 normalbg = #FFFFFF warningdays = 20 warningbg = #FFFF00 errorbg = #FF0000 weminline = false includeruntime = true failedonly = False showoffline = False

Unfortunately, there was no indication of Error or Warning in the subject line of the mail report. I hope the log file of this trial run helps to track down the issue.

wechsler42 commented 3 years ago

Hi there, I run the second trial for case: title = Duplicati Backup Summary Report #ERROR##WARNING# with this command: ./dupReport.py -i -v7 and this report section in my .rc file: [report] layout = srcdest, noactivity, lastseen columns = source:Source, destination:Destination, date:Date, time:Time, duration:Duration, dupversion:Version, examinedFiles:Files, examinedFilesDelta:+/-, sizeOfExaminedFiles:Size, fileSizeDelta:+/-, addedFiles:Added, deletedFiles:Deleted, modifiedFiles:Modified, filesWithError:File Errors, parsedResult:Result, messages:Messages, warnings:Warnings, errors:Errors, logdata:Log Data title = Duplicati Backup Summary Report #ERROR##WARNING# titlebg = #FFFFFF border = 1 padding = 5 sizedisplay = mb repeatcolumntitles = true suppresscolumntitles = false durationzeroes = true displaymessages = false jobmessagebg = #FFFFFF displaywarnings = true jobwarningbg = #FFFF00 displayerrors = true joberrorbg = #FF0000 displaylogdata = true truncatemessage = 0 truncatewarning = 0 truncateerror = 0 truncatelogdata = 0 joblogdatabg = #FF0000 nobackupwarn = 0 nbwsubject = Backup Warning: #SOURCE##DELIMITER##DESTINATION# Backup Not Seen for #DAYS# Days groupheadingbg = #D3D3D3 normaldays = 5 normalbg = #FFFFFF warningdays = 20 warningbg = #FFFF00 errorbg = #FF0000 weminline = false includeruntime = true failedonly = False showoffline = False

Unfortunately, there was again no indication of Error or Warning in the subject line of the mail report. I hope the log file of this second trial run helps to track down the issue.

wechsler42 commented 3 years ago

Hi there, I may have found a part of the solution to this issue.

If Duplicati Backup report for .... contains lines like: "ParsedResult: Error" "ParsedResult: Warning" then it works fine :-)

If the Duplicati Backup report for ... only contains lines like this: "Failed: Found 3 remote files that are not recorded in local storage, please run repair" "2021-05-27 16:37:24 +02 - [Error-Duplicati.Library.Main.Operation.BackupHandler-FatalError]: Fatal error" then there is again no indication of Error or Warning in the subject line of the dupReport mail report.

HandyGuySoftware commented 3 years ago

Ah, I was just reviewing the code and getting to the same conclusion when you beat me to it :-)

I'll think of a clean way to address the issue and post new code, possibly later today.

HandyGuySoftware commented 3 years ago

OK, I think I have it figured out. "Failure" is not an official Duplicati result code, it's just created internally by dupReport whenever anything unusual happens or it sees a non-standard email while it runs. I have accounted for that now by adding a new #FAILURE# keyword you can use in the command line. I also added 2 more keywords:

ALL# - Equivalent to #SUCCESS##WARNING##ERROR##FAILURE

ANYERROR# - Equivalent to #WARNING##ERROR##FAILURE

Try the new Issue_172 branch code and see if this works for you now.

wechsler42 commented 3 years ago

Hi there, thanks for bringing this new feature to dupReport It is working now in all my use cases with warnings, fails and errors in several Duplicati backup reports. It also works on the GMX mail server in both cases when the keyword(s) are placed at the beginning or at the end of dupReport subject line.

HandyGuySoftware commented 3 years ago

Great to hear! Let's leave it running for a few days to see if it gives you any problems. If it's still looking good after the weekend I will promote it to the master branch.

HandyGuySoftware commented 3 years ago

@wechsler42 , how is the change working for you? Did you have any problems over the weekend?

wechsler42 commented 3 years ago

Hi there, it is working without any flaws. Thanks again for implementing this feature!

HandyGuySoftware commented 3 years ago

Added to 3.0.6.