Bacula-users

Re: [Bacula-users] Mounting storage before job start

2010-08-12 15:45:04
Subject: Re: [Bacula-users] Mounting storage before job start
From: Chris Shelton <cshelton AT shelton-family DOT net>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 12 Aug 2010 15:17:03 -0400
Felix,

On Thu, Aug 12, 2010 at 10:07 AM, Felix Brack <fb AT ltec DOT ch> wrote:

On Bacula 5.0.2 I would like to mount the storage before a backup job
starts in case it was unmounted by 'umount' before.


The following works fairly well for me, as an Admin job that is scheduled to start 5 minutes before our normal nightly backups:
Job {
  Name = "MountSDLTTape"
  JobDefs = "AdminDefaultJob"
  FileSet = "Catalog"
  Schedule = "WeeklyCycleMountTape"
  Client = cheddar-fd
  # This script mounts the SDLT-Tape-1 drive
  RunScript {
    RunsOnClient = No
    RunsWhen = Before                                                                    
    Command = "/root/batch/scripts/bacula/bacula_mount_sdlt_tape.sh"                                                            
  }                                                                                                                              
  Priority = 5
}

The shell script that is run is just this:

#!/bin/sh
# mounts a tape by calling bconsole

mtdev="/dev/nst0"
dev="SDLT-Tape-1"
sbindir="/usr/sbin"
confdir="/etc/bacula"

# is tape already mounted in bacula?
echo "status storage=$dev" | $sbindir/bconsole | grep "Device \"$dev\" (/dev/nst0) is mounted"
RC=$?

if [ $RC -eq "0" ]
then
    echo "tape already mounted in bacula."
    exit 0
fi

echo "mount storage=$dev" | $sbindir/bconsole -c $confdir/bconsole-fms.conf



By the way, the opposite (unmounting) does not work too:

RunScript {
  RunsWhen = After
  Command = "echo 'unmount storage=kvm1-sd' | /usr/bin/bconsole"
  Command = "/bin/mt -f /dev/nst0 eject"
}

This ends with 'ClientAfterJob: /dev/nst0: Device or resource busy'
which I understand since the 'unmount' command did not work, the storage
daemon still locks the device.


I have another unmount shell script that runs from a different Admin job well after the normal backup window is finished, and running with a higher priority to unmount the tape.  

It seemed easier to me to put together a small shell script rather than trying to get the quoting & pipelining to work directly from a bacula RunScript.  This approach has worked reliably for me to mount and unmount a single tape drive for a few years now.

chris

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
<Prev in Thread] Current Thread [Next in Thread>