[pve-devel] [RFC pve-storage 2/3] Include incremental zfs send in storage_migrate.

Wolfgang Link w.link at proxmox.com
Mon Apr 3 16:53:41 CEST 2017


When replica is enabled and the target host is the reptarget,
the most VM data are on the new target.
---
 PVE/Storage.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index eb7000f..964102c 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -32,6 +32,7 @@ use PVE::Storage::GlusterfsPlugin;
 use PVE::Storage::ZFSPoolPlugin;
 use PVE::Storage::ZFSPlugin;
 use PVE::Storage::DRBDPlugin;
+use PVE::ReplicaTools;
 
 # Storage API version. Icrement it on changes in storage API interface.
 use constant APIVER => 1;
@@ -603,14 +604,18 @@ sub storage_migrate {
 	    my $zfspath = "$scfg->{pool}\/$volname";
 
 	    my $snap = ['zfs', 'snapshot', "$zfspath\@__migration__"];
+	    my $send = ['zfs', 'send', '-Rpv'];
+	    my $rec = ['ssh', "root\@$target_host", 'zfs', 'recv','-F' ,$zfspath];
 
-	    my $send = [['zfs', 'send', '-Rpv', "$zfspath\@__migration__"], ['ssh', "root\@$target_host",
-			'zfs', 'recv', $zfspath]];
+if (my $snap = PVE::ReplicaTools::get_rep_snap($volid)) {
+		push @$send, '-I', "$zfspath\@$snap";
+	    }
+	    push @$send, "--", "$zfspath\@__migration__";
 
 	    my $destroy_target = ['ssh', "root\@$target_host", 'zfs', 'destroy', "$zfspath\@__migration__"];
  	    run_command($snap);
 	    eval{
-		run_command($send);
+		run_command([$send,$rec]);
 	    };
 	    my $err = $@;
 	    warn "zfs send/receive failed, cleaning up snapshot(s)..\n" if $err;
-- 
2.1.4





More information about the pve-devel mailing list