]> git.proxmox.com Git - pve-zsync.git/blobdiff - pve-zsync
Fix send_config with IPv6
[pve-zsync.git] / pve-zsync
index bc06ae12cddfd433523306318275f8f5658dfddd..b3241ff2f19ddd2ae4b33a1b966a0e4281e29714 100644 (file)
--- a/pve-zsync
+++ b/pve-zsync
@@ -508,7 +508,7 @@ sub init {
     die "Config already exists\n" if $cfg->{$job->{source}}->{$job->{name}};
 
     #check if vm has zfs disks if not die;
-    get_disks($source, 1) if $source->{vmid};
+    get_disks($source) if $source->{vmid};
 
     update_cron($job);
     update_state($job);
@@ -724,7 +724,7 @@ sub write_cron {
 }
 
 sub get_disks {
-    my ($target, $get_err) = @_;
+    my ($target) = @_;
 
     my $cmd = [];
     push @$cmd, 'ssh', "root\@$target->{ip}", '--', if $target->{ip};
@@ -739,7 +739,7 @@ sub get_disks {
 
     my $res = run_cmd($cmd);
 
-    my $disks = parse_disks($res, $target->{ip}, $target->{vm_type}, $get_err);
+    my $disks = parse_disks($res, $target->{ip}, $target->{vm_type});
 
     return $disks;
 }
@@ -762,16 +762,15 @@ sub run_cmd {
 }
 
 sub parse_disks {
-    my ($text, $ip, $vm_type, $get_err) = @_;
+    my ($text, $ip, $vm_type) = @_;
 
     my $disks;
 
     my $num = 0;
     while ($text && $text =~ s/^(.*?)(\n|$)//) {
        my $line = $1;
-       my $error = $vm_type eq 'qemu' ? 1 : 0 ;
 
-       next if $line =~ /cdrom|none/;
+       next if $line =~ /media=cdrom/;
        next if $line !~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): /;
 
        #QEMU if backup is not set include in  sync
@@ -792,9 +791,9 @@ sub parse_disks {
                    last;
                }
            }
-
-       } else {
-           print "Disk: \"$line\" will not include in pve-sync\n" if $get_err || $error;
+       }
+       if (!defined($disk) || !defined($stor)) {
+           print "Disk: \"$line\" has no valid zfs dataset format and will be skipped\n";
            next;
        }
 
@@ -949,7 +948,7 @@ sub send_image {
                run_cmd(['scp', '--', $source_target, "root\@[$dest->{ip}]:$dest_target_new"]);
            } elsif ($source->{ip}) {
                run_cmd(['mkdir', '-p', '--', $config_dir]);
-               run_cmd(['scp', '--', "root\@$source->{ip}:$source_target", $dest_target_new]);
+               run_cmd(['scp', '--', "root\@[$source->{ip}]:$source_target", $dest_target_new]);
            }
 
            if ($source->{destroy}){