Hi,
in addition to an email if a backup job fails I would like to use a hook script which sends a "ping" to healthchecks.io only if no error happened. But unfortunately I did not find a easy solution yet to determine the overall job information in the hook script. I would avoid parsing journalctl entries like the creator of this thread: https://forum.proxmox.com/threads/healthchecks-io-backup-hook-script.131526/
To me, parsing journalctl looks like a workaround for a missing phase like "job-end-with-errors" in VZDump.pm. I am thinking of patching VZDump.pm like this:
For research I am printing all available information in hook script:
In addition I created a backup job which fails:
An additional phase which is called after the log output "Backup job finished with errors" would be a great feature Do you agree?
Best regards
in addition to an email if a backup job fails I would like to use a hook script which sends a "ping" to healthchecks.io only if no error happened. But unfortunately I did not find a easy solution yet to determine the overall job information in the hook script. I would avoid parsing journalctl entries like the creator of this thread: https://forum.proxmox.com/threads/healthchecks-io-backup-hook-script.131526/
To me, parsing journalctl looks like a workaround for a missing phase like "job-end-with-errors" in VZDump.pm. I am thinking of patching VZDump.pm like this:
Code:
eval { $self->run_hook_script ('job-abort', undef, $job_end_fd); };
$err .= $@ if $@;
debugmsg ('err', "Backup job failed - $err", undef, 1);
} else {
if ($errcount) {
debugmsg ('info', "Backup job finished with errors", undef, 1);
++ eval { $self->run_hook_script ('job-end-with-errors', undef, $job_end_fd); };
} else {
For research I am printing all available information in hook script:
Code:
#!/usr/bin/perl -w
use strict;
print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
print "Phase-DEBUG $phase";
print "Env-DEBUG $ENV{JOBID}";
while ( my($env_name,$env_value) = each %ENV ) {
print "\t$env_name = $env_value\n";
}
In addition I created a backup job which fails:
Code:
INFO: HOOK: job-init
INFO: Phase-DEBUG job-init
INFO: starting new backup job: vzdump 203 --all 0 --mailto xxxx --storage blub-simu-test --mode snapshot --compress zstd --node hv04 --fleecing 0 --notes-template '{{guestname}}' --mailnotification always
INFO: HOOK: job-start
INFO: Phase-DEBUG job-start
ERROR: Backup of VM 203 failed - unable to create temporary directory '/opt/immutable//dump/vzdump-qemu-203-2024_06_01-09_47_29.tmp' at /usr/share/perl5/PVE/VZDump.pm line 1055.
INFO: Failed at 2024-06-01 09:47:29
INFO: HOOK: backup-abort snapshot 203
INFO: Phase-DEBUG backup-abort
INFO: HOOK: log-end snapshot 203
INFO: Phase-DEBUG log-end
INFO: HOOK: job-end
INFO: Phase-DEBUG job-end
INFO: Backup job finished with errors
INFO: notified via target `<xxxxx>`
TASK ERROR: job errors
An additional phase which is called after the log output "Backup job finished with errors" would be a great feature Do you agree?
Best regards