From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8FFF81FF191 for ; Tue, 23 Sep 2025 19:40:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0A19C14279; Tue, 23 Sep 2025 19:40:50 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Tue, 23 Sep 2025 19:40:06 +0200 MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Constantin Herold via pve-devel Precedence: list Cc: Constantin Herold X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH pve-manager 0/1] feat: pass backup status to hook script on job-end/job-abort Content-Type: multipart/mixed; boundary="===============1093975842395597713==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============1093975842395597713== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CD233D4AC3 for ; Tue, 23 Sep 2025 19:40:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A01CC1424F for ; Tue, 23 Sep 2025 19:40:47 +0200 (CEST) Received: from core.fw.herold.me (unknown [IPv6:2a06:de00:1337:beef::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 23 Sep 2025 19:40:44 +0200 (CEST) From: Constantin Herold DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herold.me; s=mail; t=1758649238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6i1G15sFAvBSindC03Ufhs6CcSHOqzthety+jYhpkgA=; b=KnsbJhokAxhH3I/KrCq0brarCYIsL1Mf5cuwAB2kp0odMckdIF5j0hrPSquwyA2rONS8/I 5L1NrdLYICi5hDEr22heGVYolcYX0J7e47MFASXLX9tnGmyltaSz+pjR2tyQ0a1YREvUCl RDXQZLx/6rb4ivcmTPtTEN8doc7ufE+mSzlIStkQ+/QavndpRwDrBoO9OcpdX1BRt4z+ex 0XmeArDcR0bTqtC+0PJV3hbTv410+PpkHVBnW0PV8HQ3ZD228e8HTv4W3D4k6wDH/CG/wH XyJpvqNOw5cpyyv2ZQqSZ1lVy7n5JPQmLiQ5zJ6Cvx3jY5gV+C+h33g7UMHz4A== 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 X-MS-Reactions: disallow Message-Id: <20250923174007.84121-1-proxmox8914@herold.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy KAM_INFOUSMEBIZ 0.75 Prevalent use of .info|.us|.me|.me.uk|.biz|xyz|id|rocks|life domains in spam/malware RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backuphook.sh,vzdump.pm,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 --===============1093975842395597713== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============1093975842395597713==--