Commit 2e022063 authored by Dietmar Maurer's avatar Dietmar Maurer

fix bug 45: skip external VMs

parent 7dcce29d
......@@ -65,7 +65,27 @@ __PACKAGE__->register_method ({
# convert string lists to arrays
my @vmids = PVE::Tools::split_list(extract_param($param, 'vmid'));
$param->{vmids} = PVE::VZDump::check_vmids(@vmids) if !$param->{all};
my $skiplist = [];
if (!$param->{all}) {
if (!$param->{node}) {
my $vmlist = PVE::Cluster::get_vmlist();
my @localvmids = ();
foreach my $vmid (@vmids) {
my $d = $vmlist->{ids}->{$vmid};
if ($d && ($d->{node} ne $nodename)) {
push @$skiplist, $vmid;
} else {
push @localvmids, $vmid;
}
}
@vmids = @localvmids;
# silent exit if specified VMs run on other nodes
exit(0) if !scalar(@vmids);
}
$param->{vmids} = PVE::VZDump::check_vmids(@vmids)
}
my @exclude = PVE::Tools::split_list(extract_param($param, 'exclude'));
$param->{exclude} = PVE::VZDump::check_vmids(@exclude);
......@@ -79,7 +99,7 @@ __PACKAGE__->register_method ({
die "you can only backup a single VM with option --stdout\n"
if $param->{stdout} && scalar(@vmids) != 1;
my $vzdump = PVE::VZDump->new($cmdline, $param);
my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
my $worker = sub {
$SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
......
......@@ -416,7 +416,7 @@ my $sendmail = sub {
};
sub new {
my ($class, $cmdline, $opts) = @_;
my ($class, $cmdline, $opts, $skiplist) = @_;
mkpath $logdir;
......@@ -450,7 +450,8 @@ sub new {
$opts->{dumpdir} =~ s|/+$|| if ($opts->{dumpdir});
$opts->{tmpdir} =~ s|/+$|| if ($opts->{tmpdir});
my $self = bless { cmdline => $cmdline, opts => $opts };
$skiplist = [] if !$skiplist;
my $self = bless { cmdline => $cmdline, opts => $opts, skiplist => $skiplist };
#always skip '.'
push @{$self->{findexcl}}, "'('", '-regex' , "'^\\.\$'", "')'", '-o';
......@@ -957,7 +958,9 @@ sub exec_backup {
my $opts = $self->{opts};
debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1);
debugmsg ('info', "skip external VMs: " . join(', ', @{$self->{skiplist}}))
if scalar(@{$self->{skiplist}});
my $tasklist = [];
if ($opts->{all}) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment