Use a uniq temporary mount point for each LVM snapshot, so you can have one VM with two disk, stored on two different LVM volumes
This commit is contained in:
parent
c7273ea5c3
commit
a06de6ee25
10
virt-backup
10
virt-backup
|
@ -331,6 +331,9 @@ sub prepare_backup{
|
||||||
# localhost:/vmstore as the device, but this GlusterFS volume might be backed by an LVM
|
# localhost:/vmstore as the device, but this GlusterFS volume might be backed by an LVM
|
||||||
# volume, in which case, you can pass it as an argument to the script
|
# volume, in which case, you can pass it as an argument to the script
|
||||||
my $lvm = ($opts{lvm} ne '' && -e "$opts{lvm}") ? $opts{lvm} : $dev;
|
my $lvm = ($opts{lvm} ne '' && -e "$opts{lvm}") ? $opts{lvm} : $dev;
|
||||||
|
my $mp = $lvm;
|
||||||
|
$mp =~ s!/!_!g;
|
||||||
|
$mp = "$backupdir.mount/$mp";
|
||||||
# Try to snapshot this device
|
# Try to snapshot this device
|
||||||
if ( $opts{snapshot} ){
|
if ( $opts{snapshot} ){
|
||||||
# Maybe the LVM is already snapshoted and mounted for a previous disk ?
|
# Maybe the LVM is already snapshoted and mounted for a previous disk ?
|
||||||
|
@ -346,14 +349,15 @@ sub prepare_backup{
|
||||||
print "$lvm seems to be a valid logical volume (LVM), a snapshot has been taken as " .
|
print "$lvm seems to be a valid logical volume (LVM), a snapshot has been taken as " .
|
||||||
$lvm . $time ."\n" if ($opts{debug});
|
$lvm . $time ."\n" if ($opts{debug});
|
||||||
my $snap = $lvm.$time;
|
my $snap = $lvm.$time;
|
||||||
|
mkdir $mp || die "Couldn't create $mp: $!";
|
||||||
# -o nouuid is needed if XFS is used
|
# -o nouuid is needed if XFS is used
|
||||||
system("/bin/mount -o nouuid $snap $backupdir.mount");
|
system("/bin/mount -o nouuid $snap $mp");
|
||||||
open MOUNT, ">$backupdir.meta/mount";
|
open MOUNT, ">$backupdir.meta/mount";
|
||||||
print MOUNT $lvm;
|
print MOUNT $lvm;
|
||||||
close MOUNT;
|
close MOUNT;
|
||||||
}
|
}
|
||||||
my $file = $source;
|
my $file = $source;
|
||||||
$file =~ s|$mount|$backupdir.mount|;
|
$file =~ s|$mount|$mp|;
|
||||||
push (@disks, {source => $file, target => $target, type => 'file'});
|
push (@disks, {source => $file, target => $target, type => 'file'});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -487,7 +491,7 @@ sub run_cleanup{
|
||||||
# Now, standard filesystems
|
# Now, standard filesystems
|
||||||
foreach (@mounts){
|
foreach (@mounts){
|
||||||
my @info = split(/\s+/, $_);
|
my @info = split(/\s+/, $_);
|
||||||
next unless ($info[1] eq "$backupdir.mount");
|
next unless ($info[1] =~ /^$backupdir.mount/);
|
||||||
print "Found temporary mount point: $info[1]\n" if ($opts{debug});
|
print "Found temporary mount point: $info[1]\n" if ($opts{debug});
|
||||||
my $mp = $info[1];
|
my $mp = $info[1];
|
||||||
print "Unmounting $mp\n\n" if ($opts{debug});
|
print "Unmounting $mp\n\n" if ($opts{debug});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user