> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bacula-users-
> [EMAIL PROTECTED] On Behalf Of Arno Lehmann
> Sent: Saturday, January 26, 2008 4:13 PM
> To: bacula-users@lists.sourceforge.net
> Subject: Re: [Bacula-users] Multiple TapeDrives but No Autochanger
>
> Hi,
>
> 25.01.2008 15:05, Christian Sabelmann wrote:
> > Hello, I try to get Bacula to work with 2 Tapedrives concurrently.
> > The goal is to use a pseudo changer or vitual autochanger, because a
> I
> > want every Job to use this device and also the same Pool.
> > This pseudo changer should be capable of choosing one free drive to
> > write, and if a volume is requested by bacula, then
> > it should not be important if the volume is inserted in the first or
> the
> > second tape drive, unless the drive is already writing for another
> Job.
> >
> > I been looking old mails and found that there are other people having
> > the same problem. There is a script written by "Mario Wolff
> > " which can be found in the mail archive.  28/JAN/2005.
>
> Good. I was about to point you to it :-)
>
> > I tried this out but it did not work because the pseudo changer using
> > /dev/null as Changer is not recognized by Bacula
> > (VER. 2.2.6)
> >
> > Have anyone tried out some script like this to manage this problem?
> did
> > it work? or do you have some Ideas how to make it work?
>
> Disclaimer: I have never personally used that approach...
>
> But I'm pretty sure that with some changes in Bacula since 2005, the
> script would need some work done. Mainly because Baculas way to select
> drives has been refined a lot, though this shouldn't matter in a
> situation where there exists only one device known to it.
>
> Regarding your current problem, I'd try using any /dev/sgX (linux
> terminology) device as the cahnger device in the configuration (though
> I don't see why /dev/null wouldn't work). You're not actually using
> this device, so no harm will be done.
>
> Currently, as I hevent't looked at Marios script in ages, I would
> suggest you read it carefully to understand how it's doing its work,
> and where things might fail. As stated above, I would expect some
> modifications to be required.
>
> Hope this helps,
>
> Arno
>
> >
> >
>
> --
> Arno Lehmann
> IT-Service Lehmann
> www.its-lehmann.de
>
> -----------------------------------------------------------------------
> --
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Bacula-users mailing list
> Bacula-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bacula-users

I was looking for a solution to this problem about 6 months ago and was able to 
find a successful solution using the Mario Wolff script with some 
modifications.  The original script by Mario is included in the source in the 
file examples/autochangers/multiple-drive-changer.txt.

Mario's script needed some modification to work properly for me (I assume it is 
differences between Bacula 1.x and Bacula 2.x).  These modifications allow 
Bacula to think it is dealing with a 2 slot autochanger with 1 drive which 
allows my backup jobs to span multiple tapes without having an actual 
autochanger.  The "slots" are actually the tape drives and the script uses a 
soft link called /dev/tape to point at the physical drive that it wants to use. 
 In my setup, I am keeping the "slot inventory" in files inside 
/etc/bacula/tapelabel/ called SLOT01 and SLOT02.

Below are my Bacula conf files and a copy of my modified script (most of the 
script is written by Mario Wolff, just some minor changes mainly with the exit 
codes).  Let me know if you have any questions.  I have been using this 
successfully for about 4 months and it works great.

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 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 "0\n"
    return
  else
    count=1
    slotdev=$( getdevice $count )
    while [ "$slotdev" ]; do
      if [ "$slotdev" = "$device" ];then
        echo -en "$count\n"
        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
     ;;
esac


case $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

Bob Duman
Senior Systems Engineer
Cleantech Group LLC
http://www.cleantech.com



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to