die "interrupted by signal\n";
};
- $vzdump->getlock (); # only one process allowed
+ eval {
+ $vzdump->getlock(); # only one process allowed
+ };
+ if ($@) {
+ $vzdump->sendmail([], 0, $@);
+ exit(-1);
+ }
if (defined($param->{ionice})) {
if ($param->{ionice} > 7) {
}
}
-my $sendmail = sub {
- my ($self, $tasklist, $totaltime) = @_;
+sub sendmail {
+ my ($self, $tasklist, $totaltime, $err) = @_;
my $opts = $self->{opts};
}
}
- my $stat = $ecount ? 'backup failed' : 'backup successful';
+ my $stat = ($ecount || $err) ? 'backup failed' : 'backup successful';
+ $stat .= ": $err" if $err;
my $hostname = `hostname -f` || PVE::INotify::nodename();
chomp $hostname;
if (!open (SERVER_FLCK, ">>$lockfile")) {
debugmsg ('err', "can't open lock on file '$lockfile' - $!", undef, 1);
- exit (-1);
+ die "can't open lock on file '$lockfile' - $!";
}
if (flock (SERVER_FLCK, LOCK_EX|LOCK_NB)) {
if (!$maxwait) {
debugmsg ('err', "can't aquire lock '$lockfile' (wait = 0)", undef, 1);
- exit (-1);
+ die "can't aquire lock '$lockfile' (wait = 0)";
}
debugmsg('info', "trying to get global lock - waiting...", undef, 1);
if ($err) {
debugmsg ('err', "can't aquire lock '$lockfile' - $err", undef, 1);
- exit (-1);
+ die "can't aquire lock '$lockfile' - $err";
}
debugmsg('info', "got global lock", undef, 1);
my $totaltime = time() - $starttime;
- eval { $self->$sendmail ($tasklist, $totaltime); };
+ eval { $self->sendmail ($tasklist, $totaltime); };
debugmsg ('err', $@) if $@;
die $err if $err;