Bacula-users

[Bacula-users] Automatic Eject tape once job finishes

2010-05-17 07:26:34
Subject: [Bacula-users] Automatic Eject tape once job finishes
From: taisgeal <bacula-forum AT backupcentral DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Mon, 17 May 2010 07:24:35 -0400

James Harper wrote:
> 
> > 
> > Try using "RunAfterJob" option on the Job definition with a command
> > 
> like "mt -
> 
> > f /dev/st0 eject" (using you scsi device path of course)
> > 
> > 
> 
> I don't think there is a StorageRunAfterJob, so your suggestion would
> run it on the director which only works if the sd and the director are
> the same machine.
> 
> I suggest something like:
> 
> . Create an account on the sd with a minimum of privileges
> . Set up ssh public key authentication so that the account the director
> is running as can ssh to the new account on the sd
> . Configure the RunAfterJob to ssh to the sd and run the required
> command (eg the mt -f /dev/st0 command)
> 
> You will either need to make the new account on the sd a member of the
> group that owns the tape device, or use sudo. Sudo might be better as it
> would restrict the account to only ejecting. Your eject script may need
> to issue bconsole commands to do the right things with the tape library
> too if required.
> 
> James
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Bacula-users mailing list
> Bacula-users < at > lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bacula-users


Thanks for the idea, James. I tried what you suggested, but then tailored it to 
my own needs.

What I have done is to write a script which runs on server2 on Fridays at 
6.30AM, which simply unloads the tape. In case it helps anyone else, here is 
the script :

#!/bin/sh
#
# Set script variables
BACULA=/sbin/bacula
CHANGER=/etc/bacula/mtx-changer
SLEEP='/bin/sleep 20'
DRIVE=/dev/sg0
DEVICE=/dev/nst0
export BACULA CHANGER SLEEP DRIVE DEVICE
#
# Shut down Bacula so that the drive can be acessed
$BACULA stop
# 
# Allow 20 seconds for storage daemon to stop
$SLEEP
#
# Find out which tape slot the drive was loaded from
export SLOT=`$CHANGER $DRIVE loaded 0 $DEVICE 0`
#
# Unload the tape back into its original slot
$CHANGER $DRIVE unload $SLOT $DEVICE 0
#
# Start Bacula again
$BACULA start

It is fairly generic, so could be used as is or else adapted fairly easily.

Thanks again.

+----------------------------------------------------------------------
|This was sent by taisgeal AT hotmail DOT com via Backup Central.
|Forward SPAM to abuse AT backupcentral DOT com.
+----------------------------------------------------------------------



------------------------------------------------------------------------------

_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users