]> git.proxmox.com Git - pve-zsync.git/commitdiff
fix bug #813: allow mountpoints or VMdisk which are not on zfs, if they are not inclu...
authorWolfgang Link <w.link@proxmox.com>
Wed, 11 Nov 2015 09:24:52 +0000 (10:24 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 14 Nov 2015 17:32:55 +0000 (18:32 +0100)
LXC: MP are in the default setting exclude from backup, so we do not sync mp at default.
if they have the flag backup=1 we sync them.
QEMU: VMDisk will be synced always except they have a flag backup=no.

pve-zsync

index 283b55c31d9fa9b3611ffae13d825857ecdd974c..f824fc45a18458cb59c56c305c1692ad6e9aca6e 100644 (file)
--- a/pve-zsync
+++ b/pve-zsync
@@ -479,11 +479,15 @@ sub init {
 
     my $vm_type = vm_exists($source);
     $job->{vm_type} = $vm_type;
+    $source->{vm_type} = $vm_type;
 
     die "VM $source->{vmid} doesn't exist\n" if $param->{vmid} && !$vm_type;
 
     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};
+
     update_cron($job);
     update_state($job);
 
@@ -698,7 +702,7 @@ sub write_cron {
 }
 
 sub get_disks {
-    my ($target) = @_;
+    my ($target, $get_err) = @_;
 
     my $cmd = [];
     push @$cmd, 'ssh', "root\@$target->{ip}", '--', if $target->{ip};
@@ -713,7 +717,7 @@ sub get_disks {
 
     my $res = run_cmd($cmd);
 
-    my $disks = parse_disks($res, $target->{ip}, $target->{vm_type});
+    my $disks = parse_disks($res, $target->{ip}, $target->{vm_type}, $get_err);
 
     return $disks;
 }
@@ -736,24 +740,32 @@ sub run_cmd {
 }
 
 sub parse_disks {
-    my ($text, $ip, $vm_type) = @_;
+    my ($text, $ip, $vm_type, $get_err) = @_;
 
     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 !~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): /;
 
+       #QEMU if backup is not set include in  sync
+       next if $vm_type eq 'qemu && ($line =~ m/backup=(?i:0|no|off|false)/)';
+
+       #LXC if backup is not set do no in sync
+       $error = ($line =~ m/backup=(?i:1|yes|on|true)/) if $vm_type eq 'lxc';
+
        my $disk = undef;
        my $stor = undef;
        if($line =~ m/^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): (.+:)([A-Za-z0-9\-]+),(.*)$/) {
            $disk = $3;
            $stor = $2;
        } else {
-           die "disk is not on ZFS Storage\n";
+           print "Disk: \"$line\" will not include in pve-sync\n" if $get_err || $error;
+           next;
        }
 
        my $cmd = [];
@@ -796,6 +808,7 @@ sub parse_disks {
        }
     }
 
+    die "Vm include no disk on zfs.\n" if !$disks->{0};
     return $disks;
 }