]> git.proxmox.com Git - pve-zsync.git/commitdiff
close #1933: add -dest-config-path option
authorMira Limbeck <m.limbeck@proxmox.com>
Wed, 3 Apr 2019 12:23:04 +0000 (14:23 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 4 Apr 2019 14:29:13 +0000 (16:29 +0200)
this allows the config dir to be set on the destination target. this can
be useful if the default path in $CONFIG_PATH (/var/lib/pve-zsync) is not
persistent. the option is optional and falls back to $CONFIG_PATH if not
specified.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
pve-zsync

index 473d35fb96fc8fcc0cc9b6e1e62a7dd104cf92c9..425ffa2a5220ec001956e9567b59e9fbfb9a9b01 100755 (executable)
--- a/pve-zsync
+++ b/pve-zsync
@@ -220,6 +220,7 @@ sub parse_argv {
        source_user => undef,
        dest_user => undef,
        properties => undef,
+       dest_config_path => undef,
     };
 
     my ($ret) = GetOptionsFromArray(
@@ -235,6 +236,7 @@ sub parse_argv {
        'source-user=s' => \$param->{source_user},
        'dest-user=s' => \$param->{dest_user},
        'properties' => \$param->{properties},
+       'dest-config-path=s' => \$param->{dest_config_path},
     );
 
     die "can't parse options\n" if $ret == 0;
@@ -304,6 +306,7 @@ sub param_to_job {
     $job->{source_user} = $param->{source_user};
     $job->{dest_user} = $param->{dest_user};
     $job->{properties} = !!$param->{properties};
+    $job->{dest_config_path} = $param->{dest_config_path} if $param->{dest_config_path};
 
     return $job;
 }
@@ -450,6 +453,7 @@ sub format_job {
     $text .= " --source-user $job->{source_user}";
     $text .= " --dest-user $job->{dest_user}";
     $text .= " --properties" if $job->{properties};
+    $text .= " --dest-config-path $job->{dest_config_path}" if $job->{dest_config_path};
     $text .= "\n";
 
     return $text;
@@ -627,9 +631,9 @@ sub sync {
                &$sync_path($source, $dest, $job, $param, $date);
            }
            if ($param->{method} eq "ssh" && ($source->{ip} || $dest->{ip})) {
-               send_config($source, $dest,'ssh', $param->{source_user}, $param->{dest_user});
+               send_config($source, $dest,'ssh', $param->{source_user}, $param->{dest_user}, $param->{dest_config_path});
            } else {
-               send_config($source, $dest,'local', $param->{source_user}, $param->{dest_user});
+               send_config($source, $dest,'local', $param->{source_user}, $param->{dest_user}, $param->{dest_config_path});
            }
        } else {
            &$sync_path($source, $dest, $job, $param, $date);
@@ -963,12 +967,12 @@ sub send_image {
 
 
 sub send_config{
-    my ($source, $dest, $method, $source_user, $dest_user) = @_;
+    my ($source, $dest, $method, $source_user, $dest_user, $dest_config_path) = @_;
 
     my $source_target = $source->{vm_type} eq 'qemu' ? "$QEMU_CONF/$source->{vmid}.conf": "$LXC_CONF/$source->{vmid}.conf";
     my $dest_target_new ="$source->{vmid}.conf.$source->{vm_type}.$source->{new_snap}";
 
-    my $config_dir = $CONFIG_PATH;
+    my $config_dir = $dest_config_path // $CONFIG_PATH;
     $config_dir .= "/$dest->{last_part}" if $dest->{last_part};
 
     $dest_target_new = $config_dir.'/'.$dest_target_new;
@@ -1096,6 +1100,10 @@ $PROGNAME create -dest <string> -source <string> [OPTIONS]
        -properties     boolean
 
                Include the dataset's properties in the stream.
+
+       -dest-config-path    string
+
+               specify a custom config path on the destination target. default is /var/lib/pve-zsync
     },
     sync => qq{
 $PROGNAME sync -dest <string> -source <string> [OPTIONS]\n
@@ -1138,6 +1146,10 @@ $PROGNAME sync -dest <string> -source <string> [OPTIONS]\n
        -properties     boolean
 
                Include the dataset's properties in the stream.
+
+       -dest-config-path    string
+
+               specify a custom config path on the destination target. default is /var/lib/pve-zsync
     },
     list => qq{
 $PROGNAME list