Se você tem vários drives de fitas manuais num mesmo servidor e quer que o “Bacula” vá alternando entre os volumes inseridos neles (como se fosse um robô de fitas), pode ser conseguido através do script abaixo de autoria do “Mario Wolff” (um pouco modificado, o original está em: file examples/autochangers/multiple-drive-changer.txt). As modificações parecem ter sido feitas para a mudança entre as versões 1.x e 2.x do Bacula 2.x).
Neste caso, os “slots” são na verdade os drives de fita, que são chamados através de links simbólicos para: /dev/tape (exemplo), apontando para o drive físico (ex.: nst0, nst1…) que deve ser utilizado.
Exemplo de Configuração:
Bacula-sd.conf:
Device {
Name = Multitape-drive
Media Type = LTO2
Archive Device = /dev/tape
AutomaticMount = yes;
AlwaysOpen = yes;
RemovableMedia = yes;
RandomAccess = no;
Autochanger = yes
}Autochanger {
Name = Multitape-changer
Device = Multitape-drive
Changer Command = “/etc/bacula/scripts/multitape-changer %c %o %S %a %d”
Changer Device = /dev/null
}
Bacula-dir.conf:
Storage {
Name = LTO2-1
Address = backup01 # N.B. Use a fully qualified name here
SDPort = 9103
Password = “*”
Device = Multitape-changer
Autochanger = yes
Media Type = LTO2
}
Script /etc/bacula/scripts/multitape-changer:
#!/bin/bash
#
# Bacula interface to use multiple drives as one tape-changer
# Arguments are copied from the mtx-script! Simply exchange
# the scriptname from demo-config
#
# If you set in your Device resource
#
# Changer Command = “path-to-this-script/multitape-changer %c %o %S %a %d”
# you will have the following input to this script:
#
# multitape-changer “changer-device” “command” “slot” “archive-device”
“drive-index”
# $1 $2 $3 $4 $5
#
# for example:
#
# multitape-changer /dev/sg0 load 1 /dev/nst0 0 (on a Linux system)
#
# Setup arguments
cmd=”$2″
slot=$3
DEVICE=${4:-/dev/tape}LABELDIR=/etc/bacula/tapelabel # where to find labelfiles
NULLDEVICE=/dev/null # if unmount link to this
SLOT01=/dev/nst0 # first slot
SLOT02=/dev/nst1 # second slot
# simply append more#get device for a given slotnumber
getdevice(){
myslot=${1:-1}
if [ ${#myslot} -gt 2 ];then exit 1;fi
if [ ${#myslot} -eq 2 ];then
eval echo $SLOT$myslot
return
else
eval echo $SLOT0$myslot
return
fi
}#get name of labelfile for a given slot
getname(){
myslot=${1:-1}
if [ ${#myslot} -gt 2 ];then exit 2;fi
if [ ${#myslot} -eq 2 ];then
echo SLOT$myslot
return
else
echo SLOT0$myslot
return
fi
}#how many tapes/slots to manage
getslots(){
count=1
while [ “$( getdevice $count )” ];do
count=$[ $count + 1 ]
done
echo $[ $count – 1 ]
return
}#get slot for a given device-file
getslot(){
device=${1:-$NULLDEVICE}
if [ “$device” = “$NULLDEVICE” ];then
echo -en “0n”
return
else
count=1
slotdev=$( getdevice $count )
while [ “$slotdev” ]; do
if [ “$slotdev” = “$device” ];then
echo -en “$countn”
return
fi
count=$[ $count + 1 ]
slotdev=$( getdevice $count )
done
# exit 3
fi
}if test $# -lt 2 ; then
echo “usage: multitape-changer ctl-device command slot archive-device drive”
echo ” Insufficient number of arguments arguments given.”
echo ” Mimimum usage is first two arguments …”
exit 4
fi#
# Check for special cases where only 2 arguments are needed,
# all others are a minimum of 3
case $cmd in
loaded)
;;
unload)
;;
list)
;;
slots)
;;
*)
if test $# -lt 3; then
echo “usage: multitape-changer ctl-device command slot archive-device
drive”
echo ” Insufficient number of arguments arguments given.”
echo ” Mimimum usage is first three arguments …”
exit 5
fi
;;
esaccase $cmd in
unload)
if [ -e $DEVICE ];then
rm $DEVICE && ln -s $NULLDEVICE $DEVICE || exit 0
else
ln -s $NULLDEVICE $DEVICE || exit 0
fi
;;load)
CURDEV=$( getdevice $slot )
if [ -e $DEVICE ];then
rm $DEVICE && ln -s $CURDEV $DEVICE || exit 0
else
ln -s $CURDEV $DEVICE || exit 0
fi
;;list)
slots=$( getslots )
for slot in $( seq 1 $slots );do
labelfile=$LABELDIR/$( getname $slot )
if [ -f “$labelfile” ];then
echo “$slot:$( head -n 1 $labelfile)”
else
echo “$slot:”
fi
done
exit 0
;;loaded)
if [ -e $DEVICE ];then
line=$( ls -la $DEVICE )
fi
line=${line:-$NULLDEVICE}
getslot ${line##* }
sleep 1
exit 0
;;slots)
getslots
exit 0
;;
esac
Abraços,
Heitor Faria (www.bacula.com.br)
Fonte (adaptada): http://www.mail-archive.com/bacula-users@lists.sourceforge.net/msg29415.html
Disponível em: Português