diff -ruN e-smith-backup-2.4.0.tmp/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar --- e-smith-backup-2.4.0.tmp/root/etc/e-smith/events/actions/workstation-backup-dar 2014-04-19 10:43:57.000000000 -0700 +++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2014-04-19 10:53:49.000000000 -0700 @@ -63,7 +63,8 @@ my $mail = $backupwk->prop('MailNotify') || 'yes'; my $frommail = $backupwk->prop('FromMail') || 'admin-backup'; my $tomail = $backupwk->prop('ToMail') || 'admin'; -my $mntdir = ($VFSType eq 'usb') ? "\/$smbshare" : $backupwk->prop('Mount') || '/mnt/smb'; +my $mntdir = $backupwk->prop('Mount') || '/mnt/smb'; +$mntdir = "\/$smbshare" if ($VFSType eq 'usb'); # ToDo change to $backupwk->prop('Mount') my $deleteearly = $backupwk->prop('DeleteEarly') || 'false'; my $report = "From: $frommail\n"; @@ -77,33 +78,8 @@ # ping the SMB Host to see if it is awake $report .= wol ($ether,$smbhost,$smbhostmac,$smbhostdelay); -# verify backup directory not already mounted -if (!checkMount ($mntdir)) -{ - ldie("Seems backup directory is already mounted. " . - "It should not happen and maybe there is a zombie process " . - "you must kill, or another backup in progress. \n"); -} - -# create the directory mount point if it does not exist -createTree ($mntdir); - -# mount the backup directory -my $err = dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType); -ldie("Error while mounting \n" . $err) if $err; - -# verify $mntdir is mounted -if (checkMount ($mntdir)) -{ - # The mount should have suceeded, but sometimes it needs more time, - # so sleep and then check again. - sleep 5; - if (checkMount ($mntdir)) - { - ldie("Seems backup directory is not really mounted. It should not happen. \ - Verify availability of your backup volume. Stopping the backup now.\n"); - } -} +# mount backup +bmount($mntdir,$smbhost,$smbshare,$VFSType); # rotating backup indicators $incnum++; @@ -228,7 +204,7 @@ } # unmount shared folder -system("/bin/umount", "-f", "$mntdir"); +system("/bin/umount", "-f", "$mntdir") unless ($VFSType eq 'mnt'); # time now to update backup configuration $backupwk->set_prop('SetNum', $setnum); @@ -251,7 +227,10 @@ { sendReport ($report,$errmsg); } - system("/bin/umount", "$mntdir") if (!checkMount ($mntdir)); + if (($VFSType ne 'mnt') && (!checkMount ($mntdir))) + { + system("/bin/umount", "-f", "$mntdir"); + } die($errmsg); } @@ -494,3 +473,45 @@ return; } +sub bmount +{ + my ($mntdir,$host,$share,$VFSType) = @_; + # verify backup directory not already mounted + + if (!checkMount ($mntdir)) + { + return if ($VFSType eq 'mnt'); + ldie("Seems backup directory is already mounted. " . + "It should not happen and maybe there is a zombie process " . + "you must kill, or another backup in progress. \n"); + } + else + { + if ($VFSType eq 'mnt') + { + ldie("Seems backup directory is not mounted. " . + "The backup directory must be mounted when using type 'mnt'. \n"); + } + } + + # create the directory mount point if it does not exist + createTree ($mntdir); + + # mount the backup directory + my $err = dmount($host,$share,$mntdir,'','',$VFSType); + ldie("Error while mounting \n" . $err) if $err; + + # verify $mntdir is mounted + if (checkMount ($mntdir)) + { + # The mount should have suceeded, but sometimes it needs more time, + # so sleep and then check again. + sleep 5; + if (checkMount ($mntdir)) + { + ldie("Seems backup directory is not really mounted. It should not happen. \ + Verify availability of your backup volume. Stopping the backup now.\n"); + } + } + return; +}