How to Customize the Proxmox VZDump Email Notification Format for Backup Summaries.

TonnarakNET

New Member
Mar 29, 2024
1
0
1
Hi,

I want the email notification to include only the VM table results, without attaching log data. The email should provide a summary of the backup results, such as:
  1. All backups succeeded.
  2. All backups succeeded except for specific VMIDs or VMNames.
  3. All backups failed.
Thank you.
 
https://bugzilla.proxmox.com/show_bug.cgi?id=6143

In the meanwhile you can edit the notification templates in /usr/share/proxmox-ve/templates/default, just be aware that your changes can be overridden by a package upgrade. Once the override mechanism as described in the bug report is implemented, this is not the case any more.
 
Hi.

I have some questions, Where to find the variable that we can use for backups, and which template to use? does it have a list of variable templates provided?

Thank you!
 
There are three template files, vzdump-body.html.hbs, vzdump-body.txt.hbs and vzdump-subject.txt.hbs. The subject template is used for the subject for the email. The backup notification mail is sent as a multi-part message, containing a plaintext part (vzdump-body.txt.hbs) and an HTML part (vzdump-body.html.hbs). If the HTML template file does not exist, the plaintext template is used for both the plaintext part and the HTML part.

Regarding variables, there is not really much more available than what is used at the moment in the existing templates. See [1] for which data is passed to the rendering engine.

The templates are based on Handlebars templates [2], refer to [3] for a syntax reference.

The following helper functions are available for our notification templates:
  • {{ human-byte <data> }} renders a byte value to humanly readable form (e.g. 1.4GiB)
  • {{ duration <data> }} format a duration (e.g. number of seconds to 1h 4m 10s)
  • {{ timestamp <data> }} format a Unix timestamp
  • {{ table <data> }} render a table. The data that is passed must conform to the expected schema (e.g see [4] for an example)
  • {{ object <data> }} format the passed data as pretty-printed JSON

The templates and helpers are still somewhat of an implementation detail and might change once we add the override mechanism.
Then we might add additional variables or helpers.

I hope this helps. Let me know if you have any further specific questions. Also let me know if you have any wishes or suggestions for what additional variables/helpers you could need, we will consider them when adding the override mechanism.

[1] https://git.proxmox.com/?p=pve-mana...e002a6268eec456d055c9ef42f79eb8e;hb=HEAD#l531
[2] https://docs.rs/handlebars/latest/handlebars/
[3] https://handlebarsjs.com/
[4] https://git.proxmox.com/?p=proxmox....18b027018f0d13532404b205e3dc6366;hb=HEAD#l101