method => undef,
source_user => undef,
dest_user => undef,
+ properties => undef,
};
my ($ret) = GetOptionsFromArray(
'skip' => \$param->{skip},
'method=s' => \$param->{method},
'source-user=s' => \$param->{source_user},
- 'dest-user=s' => \$param->{dest_user}
+ 'dest-user=s' => \$param->{dest_user},
+ 'properties' => \$param->{properties},
);
die "can't parse options\n" if $ret == 0;
$job->{source} = $param->{source};
$job->{source_user} = $param->{source_user};
$job->{dest_user} = $param->{dest_user};
+ $job->{properties} = !!$param->{properties};
return $job;
}
$text .= " --verbose" if $job->{verbose};
$text .= " --source-user $job->{source_user}";
$text .= " --dest-user $job->{dest_user}";
+ $text .= " --properties" if $job->{properties};
$text .= "\n";
return $text;
sub vm_exists {
my ($target, $user) = @_;
- my @cmd = ('ssh', "$user\@$target->{ip}", '--') if $target->{ip};
-
- my $res = undef;
-
return undef if !defined($target->{vmid});
- eval { $res = run_cmd([@cmd, 'ls', "$QEMU_CONF/$target->{vmid}.conf"]) };
-
- return "qemu" if $res;
+ my $conf_fn = "$target->{vmid}.conf";
- eval { $res = run_cmd([@cmd, 'ls', "$LXC_CONF/$target->{vmid}.conf"]) };
-
- return "lxc" if $res;
+ if ($target->{ip}) {
+ my @cmd = ('ssh', "$user\@$target->{ip}", '--', '/bin/ls');
+ return "qemu" if eval { run_cmd([@cmd, "$QEMU_CONF/$conf_fn"]) };
+ return "lxc" if eval { run_cmd([@cmd, "$LXC_CONF/$conf_fn"]) };
+ } else {
+ return "qemu" if -f "$QEMU_CONF/$conf_fn";
+ return "lxc" if -f "$LXC_CONF/$conf_fn";
+ }
return undef;
}
$job = get_job($param);
};
- if ($job && $job->{state} eq "syncing") {
+ if ($job && defined($job->{state}) && $job->{state} eq "syncing") {
die "Job --source $param->{source} --name $param->{name} is syncing at the moment";
}
push @$cmd, 'ssh', '-o', 'BatchMode=yes', "$param->{source_user}\@$source->{ip}", '--' if $source->{ip};
push @$cmd, 'zfs', 'send';
+ push @$cmd, '-p', if $param->{properties};
push @$cmd, '-v' if $param->{verbose};
if($source->{last_snap} && snapshot_exist($source , $dest, $param->{method}, $param->{dest_user})) {
-source-user string
name of the user on the source target, root by default
+
+ -properties boolean
+
+ Include the dataset's properties in the stream.
},
sync => qq{
$PROGNAME sync -dest <string> -source <string> [OPTIONS]\n
-verbose boolean
print out the sync progress.
+
+ -properties boolean
+
+ Include the dataset's properties in the stream.
},
list => qq{
$PROGNAME list