Hello All,
When sending e-mail notifications, Kopia will use a template which is customizable. This is a great feature, but as far as I can tell it is not documented.
-
Can someone who is capable of reading source code please help posting a list of all the variables that can be used in a notification template, along with any additional information such as looping through snapshot jobs ?
-
The reason why I am looking into changing the original template is that I’m trying to add into the subject line whether there was any error on the snapshot(s) creation. Because the way it is designed right now, you have to open the email to find out the status; which is time consuming when you get a bunch of notifications from multiple cronjobs on multiple machines. I tried to put {{ .StatusCode }} in the subject, but this didn’t work as it seems to need to be inside a loop. So I’m wondering how to code a global “ALL OK” or “SOME ERROR(S)” in the subject line…
Thank you so very much !!
Robert
Default template:
kopia notification template show snapshot-report.txt
Subject: Kopia created {{ len .EventArgs.Snapshots }} snapshot{{ if gt (len .EventArgs.Snapshots) 1 }}s{{end}} on {{.Hostname}}
{{ range .EventArgs.Snapshots | sortSnapshotManifestsByName}}Path: {{ .Manifest.Source.Path }}
Status: {{ .StatusCode }}
Start: {{ .StartTimestamp | formatTime }}
Duration: {{ .Duration }}
Size: {{ .TotalSize | bytes }}{{ .TotalSizeDelta | bytesDelta }}
Files: {{ .TotalFiles | formatCount }}{{ .TotalFilesDelta | countDelta }}
Directories: {{ .TotalDirs | formatCount }}{{ .TotalDirsDelta | countDelta }}
{{ if .Error }} Error: {{ .Error }}
{{ end }}{{ if .Manifest.RootEntry }}{{ if .Manifest.RootEntry.DirSummary }}{{ if .Manifest.RootEntry.DirSummary.FailedEntries }}
Failed Entries:
{{ range .Manifest.RootEntry.DirSummary.FailedEntries }}
- {{.EntryPath}}: {{.Error}}{{ end }}{{ end }}{{ end }}
{{ end }}
{{ end }}Generated at {{ .EventTime | formatTime }} by Kopia {{ .KopiaBuildVersion }}.