From 89a82b0b9af412771ab9e896411e0e008005576c Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 9 Aug 2013 15:02:51 +0200 Subject: [PATCH] Fix LVM device name for file backed disks, so snapshot can be created. Also only use the nouuid for xfs filesystems --- virt-backup | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/virt-backup b/virt-backup index dc597ca..135ad7f 100644 --- a/virt-backup +++ b/virt-backup @@ -64,6 +64,8 @@ $opts{compress} = 'none'; $opts{lvcreate} = '/sbin/lvcreate -c 512'; # lvremove path $opts{lvremove} = '/sbin/lvremove'; +# lvs path +$opts{lvs} = '/sbin/lvs'; # Override path to the LVM backend # Usefull if you have a layer between the filesystem # and the LVM volume, like GlusterFS @@ -333,8 +335,13 @@ sub prepare_backup{ # If the disk is a file elsif ($disk->{type} eq 'file'){ # Try to find the mount point, and the backing device - my @df = `df -P $source`; - my ($dev,undef,undef,undef,undef,$mount) = split /\s+/, $df[1]; + my @df = `df -PT $source`; + my ($dev,$type,undef,undef,undef,undef,$mount) = split /\s+/, $df[1]; + # Ok, we now have the backing device which probably looks like /dev/mapper/vg-lv + # We cannot pass this arg to lvcreate to take a snapshot, wee need to detect Volume Group + # name and Logical Volume name + my (undef,$lv,$vg) = split (/\s+/, `/sbin/lvs --noheadings -o lv_name,vg_name $dev $backupdir.meta/mount"; print MOUNT $lvm; close MOUNT;