public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Constantin Herold via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Constantin Herold <proxmox8914@herold.me>
Subject: [pve-devel] [PATCH pve-manager 0/1] feat: pass backup status to hook script on job-end/job-abort
Date: Tue, 23 Sep 2025 19:40:06 +0200	[thread overview]
Message-ID: <mailman.315.1758649248.390.pve-devel@lists.proxmox.com> (raw)

[-- Attachment #1: Type: message/rfc822, Size: 4862 bytes --]

From: Constantin Herold <proxmox8914@herold.me>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 0/1] feat: pass backup status to hook script on job-end/job-abort
Date: Tue, 23 Sep 2025 19:40:06 +0200
Message-ID: <20250923174007.84121-1-proxmox8914@herold.me>

I've been using the pve manager vzdump hook to do custom things after a backup is done e.g. backup some more files, call a webhook for monitoring, etc.

However there is currently a big drawback, the job state does not get passed, so there is no way to tell whether the backup was succesfull or not.

I recently had some drive issues which resulted in 1 vm backup failing, if i had not checked the mailnotification i would have never catched that.


e.g. /etc/vzdump.conf with `script: /root/backuphook.sh`

cat << 'EOF' > /root/backuphook
#!/bin/bash

cd /tmp
DATE=$(date +"%d.%m.%Y")
FILENAME="backup_$DATE.env"
echo "" >> "$FILENAME"
chmod 700 "$FILENAME"
echo "Arguments: $@" >> "$FILENAME"
printenv >> "$FILENAME"
echo -e "\n\n" >> "$FILENAME"
EOF


all the backuphook gets passed is the following:
```
Arguments: job-end  
PWD=/tmp
LVM_SUPPRESS_FD_WARNINGS=1
SHLVL=1
STOREID=backup
LC_ALL=C
OLDPWD=/
_=/usr/bin/printenv
```

No way to tell whether the backup was succesfull, can't even grep the backup log for it etc.

I've been using this simple patch to pass the errcount to the `job-end` and `job-abort` stage

This way you can check now if it was succesfull or not, e.g:

cat << 'EOF' > /root/backuphook
#!/bin/bash

if [[ "$*" != *job-end* ]]; then
    exit 0
fi

if [ "$ERRCOUNT" -gt 0 ]; then
    # alert on broken backup (could be drive issues etc.)
    # call webhook / trigger monitoring alert
else
    # do some more things after succesfull backup
fi
EOF


Would be great if this could be merged.

Best regards
Constantin


Constantin Herold (1):
  feat: pass backup status to hook script on job-end/job-abort

 PVE/VZDump.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.51.0



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

                 reply	other threads:[~2025-09-23 17:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mailman.315.1758649248.390.pve-devel@lists.proxmox.com \
    --to=pve-devel@lists.proxmox.com \
    --cc=proxmox8914@herold.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal