diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm index 91b8a2766..2e9007856 100644 --- a/PVE/API2/VZDump.pm +++ b/PVE/API2/VZDump.pm @@ -120,8 +120,6 @@ __PACKAGE__->register_method ({ $rpcenv->check($user, "/storage/$param->{storage}", [ 'Datastore.AllocateSpace' ]) if $param->{storage}; - my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist); - my $worker = sub { my $upid = shift; @@ -129,6 +127,8 @@ __PACKAGE__->register_method ({ die "interrupted by signal\n"; }; + my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist); + eval { $vzdump->getlock($upid); # only one process allowed }; diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 3101b6a25..4587a9d14 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -391,13 +391,21 @@ sub sendmail { return if (!$ecount && !$err && ($notify eq 'failure')); my $stat = ($ecount || $err) ? 'backup failed' : 'backup successful'; - $stat .= ": $err" if $err; + if ($err) { + if ($err =~ /\n/) { + $stat .= ": multiple problems"; + } else { + $stat .= ": $err"; + $err = undef; + } + } my $hostname = `hostname -f` || PVE::INotify::nodename(); chomp $hostname; # text part - my $text = sprintf ("%-10s %-6s %10s %10s %s\n", qw(VMID STATUS TIME SIZE FILENAME)); + my $text = $err ? "$err\n\n" : ''; + $text .= sprintf ("%-10s %-6s %10s %10s %s\n", qw(VMID STATUS TIME SIZE FILENAME)); foreach my $task (@$tasklist) { my $vmid = $task->{vmid}; if ($task->{state} eq 'ok') { @@ -433,6 +441,7 @@ sub sendmail { # html part my $html = "
\n"; + $html .= "" . (escape_html($err) =~ s/\n/
/gr) . "
VMID | NAME | STATUS | TIME | SIZE | FILENAME |