X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=BackupPC_ovz;h=38e888ac0016e6e96afbde72c0bc3ffa9e6562a8;hb=HEAD;hp=2cbc86ca889b79990262893b1e9b41c8d6c37789;hpb=23d759720b40018bcfa4c5036b5a5fb2c9496e77;p=ovzbpc.git diff --git a/BackupPC_ovz b/BackupPC_ovz index 2cbc86c..38e888a 100755 --- a/BackupPC_ovz +++ b/BackupPC_ovz @@ -88,6 +88,8 @@ sub refreshConfig() # Write the VEs on all HNs to a config file on the BackupPC server for # later use. my @HNS = (); + + print $dbgf ": refreshConfig\n"; open my $cfg, "<$hnlistFile" || mydie "Cannot read $hnlistFile"; while (<$cfg>) { chomp; @@ -273,6 +275,7 @@ sub printVeEntry($) sub delSnapshot($) { my ($ve) = @_; + print $dbgf ": delSnapshot\n"; mydie "No VE record for delSnapshot" if (!defined($ve)); #print "delSnapshot: doing nothing for now\n"; @@ -282,12 +285,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($) @@ -419,25 +429,31 @@ sub restoreConfigs($) sub checkRunningClient() { + print $dbgf ": checkRunningClient, vzsnap=$vzsnap\n"; mydie "A backup or restore operation are already in progress" if (Proc::PID::File->running({ dir => '/tmp', verify => 1 })); # 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); } } @@ -451,6 +467,7 @@ sub runPing() my $host = shift(@ARGV); my $cmd = join(' ', @ARGV); + print $dbgf ": runPing host=$host, cmd=$cmd\n"; # Find $host in the list of VEs loadVeList(); my $hostname = gethostbyaddr(gethostbyname($host), AF_INET); @@ -470,6 +487,7 @@ sub runClient($) { my ($restore) = @_; + print $dbgf ": runClient restore=$restore\n"; checkRunningClient(); my $veid = shift(@ARGV); @@ -505,6 +523,8 @@ sub runClient($) # Remove snapshot, we're done delSnapshot($ve); + print $dbgf ": runClient complete\n"; + # Pass the return code back #exit $ret; FIXME: currently, cmdSystemOrEval doesn't return a retcode. exit 0; @@ -522,8 +542,9 @@ sub runClient($) sub runServer($) { my ($restore) = @_; - my $host = shift(@ARGV); + + print $dbgf ": runServer restore=$restore, host=$host\n"; mydie "Hostname argument required" if (!defined($host)); mydie "No command to execute after hostname" if ($#ARGV < 0);