Bacula磁带更改

如何让Bacula在运行特定作业后将磁带移动到IO插槽?

我几天后和Bacula进行日常备份,我想知道是否可以做这种事情。 我已经在configuration文件中指定了UseVolumeOnce = yes指令,但是现在我想知道当作业完成时是否可以让Bacula将磁带移动到插槽24(I / O插槽)。

bacula可以做到这一点,或者我需要脚本吗? 如果我需要编写脚本,你有经验吗?

如果没有相同的环境进行testing,我不确定这是否行得通,但是通过bacula-dir.conf中的RunAfterJob指令调用的脚本应该可以工作:

#!/bin/sh # echo "unmount <device-name>" | <bacula-path>/bconsole -c bconsole.conf 

如果您想避免调用外部脚本,可以尝试使用AlwaysOpen,RequiresMount / MountCommand / UnmountCommand和/或OfflineOnUnmount指令。 所有这些都位于Storage Daemonconfiguration的Device资源中。

另外,你能否澄清为什么这对你是可取的? 也许有一个解决我们忽略的根本问题。

我build立了一个名为Eject的pipe理作业,它以优先级1000运行以下脚本,所有备份完成后执行:

您也可以将其作为特定作业的“RunAfterJob”选项运行。

 #!/bin/bash MAXATTEMPTS=3 STORAGE=StorageName DEVICE=/dev/sg3 CODE=0 OUT=`mktemp /tmp/XXXXXX` ########################################################################### ## Eject the tape from the drive and determine which slot it ended up in ## ########################################################################### STATUS=1 ATTEMPT=0 while [ $STATUS -ne 0 ] && [ $ATTEMPT -lt $MAXATTEMPTS ]; do echo "umount Storage=$STORAGE"|/usr/sbin/bconsole >> $OUT if ( grep "Command Failed" $OUT > /dev/null ); then STATUS=1 echo "Command Failed!" rm $OUT else STATUS=0 cat $OUT fi ATTEMPT=$(( $ATTEMPT + 1 )) done SLOT=`tac $OUT|grep -m1 3307|cut -d" " -f6|cut -d, -f1` # Find the last occurrence of the success message only rm $OUT if [ "x$SLOT" = "x" ] || [ $STATUS -ne 0 ]; then echo "ERROR: Unable to unmount drive after $ATTEMPT attempts" exit 1 else echo "Slot $SLOT unloaded from Drive-0 " fi ########################################### ## Move the ejected tape to the I/O slot ## ########################################### STATUS=1 ATTEMPT=0 while [ $STATUS -ne 0 ] && [ $ATTEMPT -lt $MAXATTEMPTS ]; do /usr/sbin/mtx -f $DEVICE transfer $SLOT 24 STATUS=$? ATTEMPT=$(( $ATTEMPT + 1 )) done if [ $STATUS -ne 0 ]; then echo "ERROR: Unable to move tape from slot $SLOT to I/O after $ATTEMPT attempts" CODE=2 else echo "Tape moved from slot $SLOT to I/O" fi ################################# ## Ensure the DB is up to date ## ################################# echo "update slots Storage=$STORAGE"|/usr/sbin/bconsole > /dev/null if [ $CODE -ne 0 ]; then exit $CODE fi 

你必须编写脚本,但Bacula和最近版本的MTX的组合使得这并不是太痛苦。

看看“在作业之前运行”和“在作业之后运行”“作业”参数来调用你写的脚本。 我们倾向于把一个运行一个命令的脚本调用到bconsole(通过inputredirect)来卸载你的磁带卷,然后调用MTX来移动磁带。