[pve-devel] [PATCH container] backup: log errors from rsync

Fiona Ebner f.ebner at proxmox.com
Mon May 6 14:40:43 CEST 2024


Commit 5582b0c ("vzdump: rsync: make less verbose") talks about making
the output less verbose, but it likely did not intended to get rid of
the error messages from rsync, but only the uninteresting messages to
stdout.

The currently used log function is only matching the total
transferred and ignores everything else. Split it into an output and
error function and log all error messages from rsync.

Excerpt from the output with the patch:

> INFO: starting first sync /proc/55667/root/ to /mnt/tmp/vzdumptmp62235_113/
> ERROR: rsync: [sender] send_files failed to open "/proc/55667/root/foo/file": Input/output error (5)
> ERROR: rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7]
> ERROR: Backup of VM 113 failed - command 'rsync --stats -h -X -A --numeric-ids -aH --delete --no-whole-file --sparse --one-file-system --relative '--exclude=/tmp/?*' '--exclude=/var/tmp/?*' '--exclude=/var/run/?*.pid' /proc/55667/root//./ /proc/55667/root//./foo /mnt/tmp/vzdumptmp62235_113/' failed: exit code 23
> INFO: Failed at 2024-05-06 14:21:58
> INFO: Backup job finished with errors

Without the patch, the first two error messages with the root cause of
the issue would not be shown, confusing users and leaving developers
in the dark when trying to help.

Examples from the forum:
https://forum.proxmox.com/threads/146415/post-660946
https://forum.proxmox.com/threads/101810/
https://forum.proxmox.com/threads/101560/
https://forum.proxmox.com/threads/79572/post-352377

Fixes: 5582b0c ("vzdump: rsync: make less verbose")
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 src/PVE/VZDump/LXC.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 8c28a5e..671f5f8 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -52,13 +52,15 @@ my $rsync_vm = sub {
     }
 
     my $transferred = '';
-    my $logfunc = sub {
+    my $outfunc = sub {
 	return if $_[0] !~ /^Total transferred file size: (.+)$/;
 	$transferred = $1;
     };
 
+    my $errfunc = sub { $self->logerr($_[0]); };
+
     my $starttime = time();
-    PVE::Tools::run_command([@$rsync, $to], logfunc => $logfunc);
+    PVE::Tools::run_command([@$rsync, $to], outfunc => $outfunc, errfunc => $errfunc);
     my $delay = time () - $starttime;
 
     $self->loginfo ("$text sync finished - transferred $transferred in ${delay}s");
-- 
2.39.2





More information about the pve-devel mailing list