VZDump->new() dies when a tmpdir or dumpdir is configured
but does not exist. At this point the error is not being
reported via email.
This also moves the instantiation of VZDump into the worker
since new() can now call sendmail() on error.
Additionally rather than only showing a single error if both
tmpdir and dumpdir don't exist, both are included in the
message.
$rpcenv->check($user, "/storage/$param->{storage}", [ 'Datastore.AllocateSpace' ])
if $param->{storage};
$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;
my $worker = sub {
my $upid = shift;
die "interrupted by signal\n";
};
die "interrupted by signal\n";
};
+ my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
+
eval {
$vzdump->getlock($upid); # only one process allowed
};
eval {
$vzdump->getlock($upid); # only one process allowed
};
return if (!$ecount && !$err && ($notify eq 'failure'));
my $stat = ($ecount || $err) ? 'backup failed' : 'backup successful';
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 $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') {
foreach my $task (@$tasklist) {
my $vmid = $task->{vmid};
if ($task->{state} eq 'ok') {
# html part
my $html = "<html><body>\n";
# html part
my $html = "<html><body>\n";
+ $html .= "<p>" . (escape_html($err) =~ s/\n/<br>/gr) . "</p>\n" if $err;
$html .= "<table border=1 cellpadding=3>\n";
$html .= "<tr><td>VMID<td>NAME<td>STATUS<td>TIME<td>SIZE<td>FILENAME</tr>\n";
$html .= "<table border=1 cellpadding=3>\n";
$html .= "<tr><td>VMID<td>NAME<td>STATUS<td>TIME<td>SIZE<td>FILENAME</tr>\n";
$opts->{storage} = 'local';
}
$opts->{storage} = 'local';
}
if ($opts->{storage}) {
my $info = storage_info ($opts->{storage});
$opts->{dumpdir} = $info->{dumpdir};
$maxfiles = $info->{maxfiles} if !defined($maxfiles) && defined($info->{maxfiles});
} elsif ($opts->{dumpdir}) {
if ($opts->{storage}) {
my $info = storage_info ($opts->{storage});
$opts->{dumpdir} = $info->{dumpdir};
$maxfiles = $info->{maxfiles} if !defined($maxfiles) && defined($info->{maxfiles});
} elsif ($opts->{dumpdir}) {
- die "dumpdir '$opts->{dumpdir}' does not exist\n"
+ $errors .= "dumpdir '$opts->{dumpdir}' does not exist"
if ! -d $opts->{dumpdir};
} else {
die "internal error";
}
if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {
if ! -d $opts->{dumpdir};
} else {
die "internal error";
}
if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {
- die "tmpdir '$opts->{tmpdir}' does not exist\n";
+ $errors .= "\n" if $errors;
+ $errors .= "tmpdir '$opts->{tmpdir}' does not exist";
+ }
+
+ if ($errors) {
+ eval { $self->sendmail([], 0, $errors); };
+ debugmsg ('err', $@) if $@;
+ die "$errors\n";
}
$opts->{maxfiles} = $maxfiles if defined($maxfiles);
}
$opts->{maxfiles} = $maxfiles if defined($maxfiles);