From a06de6ee25a12f04067c12bf3824d053227d3eb4 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 28 Jul 2013 18:36:28 +0200 Subject: [PATCH] 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 --- virt-backup | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/virt-backup b/virt-backup index 9975cac..8a08a0e 100644 --- a/virt-backup +++ b/virt-backup @@ -331,6 +331,9 @@ sub prepare_backup{ # 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 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 if ( $opts{snapshot} ){ # 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 " . $lvm . $time ."\n" if ($opts{debug}); my $snap = $lvm.$time; + mkdir $mp || die "Couldn't create $mp: $!"; # -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"; print MOUNT $lvm; close MOUNT; } my $file = $source; - $file =~ s|$mount|$backupdir.mount|; + $file =~ s|$mount|$mp|; push (@disks, {source => $file, target => $target, type => 'file'}); } else { @@ -487,7 +491,7 @@ sub run_cleanup{ # Now, standard filesystems foreach (@mounts){ 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}); my $mp = $info[1]; print "Unmounting $mp\n\n" if ($opts{debug});