borgbase / ansible-role-borgbackup

Ansible role to set up Borg and Borgmatic
MIT License
229 stars 101 forks source link

Allow for supressing of cron email notifications #85

Open Ramblurr opened 3 years ago

Ramblurr commented 3 years ago

I'm using this role to configure backup for hosts in a Proxmox cluster. Proxmox is debian based and includes postfix out of the box to send cron notifications.

I want to leave cron notifications enabled generally, but for the borgmatic job I want to disable them (as I have healthchecks alerting me to failed runs). The proper way to do this is to either append >/dev/null 2>&1 to the command so no output is generated, or pass --verbosity=-1 to borgmatic, or to define MAILTO="" in the crontab file.

The first and second is more portable, while the third might depend on the cron implementation.

Passing the --verbosity=-1 flag will supress output in the happy-path, but if there is an error it still produces output.

Personally, I'd rather no emails be sent and instead rely on healthchecks to notify me.

I propose borgmatic_cron_supress_output boolean variable to conditionally append the /dev/null redirect to the command.