From e93c18c4abe6391b5dc7c5f47ce70fbf97880906 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Mon, 9 Dec 2013 09:09:02 -0700 Subject: [PATCH] BackupPC_ovz: add extra debug for lvremove To help in tracking down sporadic lvremove issue. --- BackupPC_ovz | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/BackupPC_ovz b/BackupPC_ovz index 2cbc86c..c6ef4bf 100755 --- a/BackupPC_ovz +++ b/BackupPC_ovz @@ -282,12 +282,19 @@ sub delSnapshot($) my $dir = $ve->{'snaproot'}; if (defined($dir) && -d $dir) { #cmdSystemOrEval("rm -rf $dir/etc/vzdump"); + print $dbgf ": delSnapshot snapshot mounted at $dir\n"; cmdSystemOrEval("umount $dir"); cmdSystemOrEval("rmdir $dir"); } my $dev = $ve->{'snapdev'}; - cmdSystemOrEval("lvremove -f $dev >/dev/null 2>&1") if (-b $dev); + #cmdSystemOrEval("lvremove -f $dev >/dev/null 2>&1") if (-b $dev); + if (-b $dev) { + print $dbgf ": removing LV $dev\n"; + system("lvremove -f $dev >>$dbgfn 2>&1") + } else { + print $dbgf ": lvremove: $dev is not block special\n"; + } } sub getDevice($) @@ -424,20 +431,25 @@ sub checkRunningClient() # Clean up any prior backup's mount point and snapshot, if it exists. # Note that the snapshot is small, so we don't really want it lying around! + # There are cases where the snapshot will not show as a snapshot, and in + # these cases the LV will not be removed by this function. my $vg = undef; open my $fh, "lvscan|" || mydie "Unable to exec lvscan"; while (my $line = <$fh>) { + #print $dbgf ": checkRunningClient lvscan line=$line\n"; if ($line =~ m|^\s+ACTIVE\s+Snapshot\s+\'/dev/([^/]+)/$vzsnap\'\s|) { $vg = $1; + #print $dbgf ": checkRunningClient vg=$vg\n"; } } close($fh); if (defined($vg)) { my $dev = "/dev/mapper/$vg-$vzsnap"; - #print "Found vzsnap lv $dev\n"; + print $dbgf ": found vzsnap lv $dev\n"; cmdSystemOrEval("umount /$vzsnap"); cmdSystemOrEval("rmdir /$vzsnap") if (-d "/$vzsnap"); - cmdSystemOrEval("lvremove -f $dev >/dev/null 2>&1") if (-b $dev); + #cmdSystemOrEval("lvremove -f $dev >/dev/null 2>&1") if (-b $dev); + system("lvremove -f $dev >>$dbgfn 2>&1") if (-b $dev); } } -- 2.39.2