[pve-devel] [PATCH zsync 4/6] snapshot_get: make interface agnostic to source/dest

Fabian Ebner f.ebner at proxmox.com
Tue May 11 14:59:53 CEST 2021


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 pve-zsync | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/pve-zsync b/pve-zsync
index ff05f46..c162230 100755
--- a/pve-zsync
+++ b/pve-zsync
@@ -677,7 +677,15 @@ sub sync {
 	my $sync_path = sub {
 	    my ($source, $dest, $job, $param, $date) = @_;
 
-	    ($dest->{old_snap}, $dest->{last_snap}) = snapshot_get($source, $dest, $param->{maxsnap}, $param->{name}, $param->{dest_user});
+	    my $dest_dataset = target_dataset($source, $dest);
+
+	    ($dest->{old_snap}, $dest->{last_snap}) = snapshot_get(
+		$dest_dataset,
+		$param->{maxsnap},
+		$param->{name},
+		$dest->{ip},
+		$param->{dest_user},
+	    );
 
 	    prepare_prepended_target($source, $dest, $param->{dest_user}) if defined($dest->{prepend});
 
@@ -746,14 +754,12 @@ sub sync {
 }
 
 sub snapshot_get{
-    my ($source, $dest, $max_snap, $name, $dest_user) = @_;
+    my ($dataset, $max_snap, $name, $ip, $user) = @_;
 
     my $cmd = [];
-    push @$cmd, 'ssh', "$dest_user\@$dest->{ip}", '--', if $dest->{ip};
+    push @$cmd, 'ssh', "$user\@$ip", '--', if $ip;
     push @$cmd, 'zfs', 'list', '-r', '-t', 'snapshot', '-Ho', 'name', '-S', 'creation';
-
-    my $path = target_dataset($source, $dest);
-    push @$cmd, $path;
+    push @$cmd, $dataset;
 
     my $raw;
     eval {$raw = run_cmd($cmd)};
-- 
2.20.1






More information about the pve-devel mailing list