5
0
mirror of git://git.proxmox.com/git/pve-zsync.git synced 2025-01-03 09:17:37 +03:00

fix bug #813: allow mountpoints or VMdisk which are not on zfs, if they are not include in backup.

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.
This commit is contained in:
Wolfgang Link 2015-11-11 10:24:52 +01:00 committed by Dietmar Maurer
parent 5a3a180e11
commit 3db33e1f60

View File

@ -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;
}