Bacula-users

[Bacula-users] [Fwd: Here you go!!!!!!]

2009-02-13 14:36:06
Subject: [Bacula-users] [Fwd: Here you go!!!!!!]
From: Brian Debelius <bdebelius AT intelesyscorp DOT com>
To: bacula-users <bacula-users AT lists.sourceforge DOT net>, Steve Handy <shandy AT firstcomm DOT com>
Date: Fri, 13 Feb 2009 14:31:42 -0500


-------- Original Message --------
Subject:        Here you go!!!!!!
Date:   Fri, 13 Feb 2009 13:09:24 -0600
From:   Steve Handy <shandy AT firstcomm DOT com>
To:     'Brian Debelius' <bdebelius AT intelesyscorp DOT com>
References: <21976504.post AT talk.nabble DOT com> <387ee2020902121325o7115f40fqf7665925ebe1131f AT mail.gmail DOT com> <32AD37B1F4606A47A1C19D381637388119EAFE54FE AT exchange7.corp.callglobalcom DOT com> <49949D55.6060604 AT intelesyscorp DOT com> <32AD37B1F4606A47A1C19D381637388119EAFE5501 AT exchange7.corp.callglobalcom DOT com> <4994A00A.3050602 AT intelesyscorp DOT com>



Good Afternoon,

Here is my setup:  Ubuntu Server - director running.  Solaris - storage server 
running and Windows Server 2003 file server - File client running.

We are using a L180 Sun Tape Library which the storage server is attached. The 
only other changes made were to the mx-changer file.

 This line was changed were the parenthesis were removed from VolumeTag on this 
line:

cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" 
| sed 's/Full.*:VolumeTag=//g'


Thanks
Steve

#
# Default Bacula Director Configuration file
#
#  The only thing that MUST be changed is to add one or more
#   file or directory names in the Include directive of the
#   FileSet resource.
#
#  For Bacula release 2.4.2 (26 July 2008) -- debian lenny/sid
#
#  You might also want to change the default email address
#   from root to your address.  See the "mail" and "operator"
#   directives in the Messages resource.
#

Director {                            # define myself
  Name = baculavm-dir
  DIRport = 9101                # where we listen for UA connections
  QueryFile = "/etc/bacula/scripts/query.sql"
  WorkingDirectory = "/var/lib/bacula"
  PidDirectory = "/var/run/bacula"
  Maximum Concurrent Jobs = 1
  Password = "fcomm"         # Console password
  Messages = Daemon
 
}

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = vcenter1-fd 
  FileSet = "Full Set"
  Storage = L180-0
  Messages = Standard
  Pool = Default
  Priority = 10
}

JobDefs {
  Name = "Windows File Server Job"
  Type = Backup
  Level = Incremental
  Client = vcenter1-fd
  FileSet = "Full Set"
  Storage = L180-0
  Messages = Standard
  Pool = Windows File Server Backup
  Priority = 10
}



#
# Define the main nightly save backup job
#   By default, this job will back up to disk in 
/nonexistant/path/to/file/archive/dir
Job {
  Name = "Client1"
  JobDefs = "DefaultJob"
  Write Bootstrap = "/var/lib/bacula/Client1.bsr"
}

Job {
  Name = "File Server Backup"
  Client = vcenter1-fd
  JobDefs = "Windows File Server Job"
  Write Bootstrap = "/var/lib/bacula/Client2.bsr"
}

# Backup the catalog database (after the nightly save)
Job {
  Name = "BackupCatalog"
  JobDefs = "DefaultJob"
  Level = Full
  FileSet="Catalog"
  #Schedule = "WeeklyCycleAfterBackup"
  # This creates an ASCII copy of the catalog
  # WARNING!
  # Ubuntu uses make_catalog_backup_awk script for
  # security reasons
  # Replace <CatalogName> with the real Catalog name
  RunBeforeJob = "/usr/bin/awk -f /etc/bacula/scripts/make_catalog_backup_awk 
-v cat1=<CatalogName> /etc/bacula/bacula-dir.conf"
  # This deletes the copy of the catalog
  RunAfterJob  = "/etc/bacula/scripts/delete_catalog_backup"
  Write Bootstrap = "/var/lib/bacula/BackupCatalog.bsr"
  Priority = 11                   # run after main backup
}

#
# Standard Restore template, to be changed by Console program
#  Only one such job is needed for all Jobs/Clients/Storage ...
#
Job {
  Name = "RestoreFiles"
  Type = Restore
  Client=vcenter1-fd                 
  FileSet="Full Set"                  
  Storage = L180-0                    
  Pool = Default
  Messages = Standard
  Where =  /tmp/bacula-restores/e
}


# List of files to be backed up
FileSet {
  Name = "Full Set"
  Include {
    Options {
      signature = MD5
      compression = GZIP
    }
#    
#  Put your list of files here, preceded by 'File =', one per line
#    or include an external list with:
#
#    File = <file-name
#
#  Note: / backs up everything on the root partition.
#    if you have other partitons such as /usr or /home
#    you will probably want to add them too.
#
#  By default this is defined to point to the Bacula build
#    directory to give a reasonable FileSet to backup to
#    disk storage during initial testing.
#
    File = "e:/"
  }

#
# If you backup the root directory, the following two excluded
#   files can be useful
#
  Exclude {
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
  }
}

#
# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sun at 23:05
  Run = Differential 2nd-5th sun at 23:05
  Run = Incremental mon-sat at 23:05
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 23:10
}

# This is the backup of the catalog
FileSet {
  Name = "Catalog"
  Include {
    Options {
      signature = MD5
    }
    File = /var/lib/bacula/bacula.sql
  }
}

# Client (File Services) to backup
Client {
  Name = vcenter1-fd
  Address = 172.16.5.144
  FDPort = 9102
  Catalog = MyCatalog
  Password = "fcomm"          # password for FileDaemon
  File Retention = 30 days            # 30 days
  Job Retention = 6 months    # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}

#
# Second Client (File Services) to backup
#  You should change Name, Address, and Password before using
#
#Client {
#  Name = baculavm2-fd                
#  Address = baculavm2
#  FDPort = 9102
#  Catalog = MyCatalog
#  Password = "Cv70F6pf1t6pBopT4vQOnigDrR0v3LT3Cg2"         # password for 
FileDaemon 2
#  File Retention = 30 days            # 30 days
#  Job Retention = 6 months            # six months
#  AutoPrune = yes                     # Prune expired Jobs/Files
#}


# Definition of file storage device
# Storage {
#  Name = File
# Do not use "localhost" here    
#  Address = 172.16.8.100                # N.B. Use a fully qualified name here
#  SDPort = 9103
#  Password = "fcomm"
#  Device = FileStorage
#  Media Type = File
# }



# Definition of DDS tape storage device
Storage {
   Name = L180-0      
   Address = 172.16.8.100          # N.B. Use a fully qualified name here
   SDPort = 9103
   Password = "fcomm"              # password for Storage daemon
   Device = Drive-1                # must be same as Device in Storage daemon
   Media Type = LTO-2              # must be same as MediaType in Storage daemon
   Autochanger = yes               # enable for autochanger device
}

# Definition of 8mm tape storage device
#Storage {
#  Name = "8mmDrive"
#  Do not use "localhost" here
#  Address = baculavm                # N.B. Use a fully qualified name here
#  SDPort = 9103
#  Password = "Cv70F6pf1t6pBopT4vQOnigDrR0v3LT3Cgkiyj"
#  Device = "Exabyte 8mm"
#  MediaType = "8mm"
#}

# Definition of DVD storage device
#Storage {
#  Name = "DVD"
#  Do not use "localhost" here
#  Address = baculavm                # N.B. Use a fully qualified name here
#  SDPort = 9103
#  Password = "Cv70F6pf1t6pBopT4vQOnigDrR0v3LT3Cgkiyj"
#  Device = "DVD Writer"
#  MediaType = "DVD"
#}


# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = "fcomm"
}

# Reasonable message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
#  to replace the %r in the from field (-f part) with a single valid
#  email address in both the mailcommand and the operatorcommand.
#  What this does is, it sets the email address that emails would display
#  in the FROM field, which is by default the same email as they're being
#  sent to.  However, if you send email to more than one address, then
#  you'll have to set the FROM address manually, to a single address. 
#  for example, a 'no-reply AT mydomain DOT com', is better since that tends to
#  tell (most) people that its coming from an automated source.

#
  mailcommand = "/usr/lib/bacula/bsmtp -h 172.16.6.106 -f \"\(Bacula\) \<%r\>\" 
-s \"Bacula: %t %e of %c %l\" %r"
  operatorcommand = "/usr/lib/bacula/bsmtp -h 172.16.6.106 -f \"\(Bacula\) 
\<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
  mail = shandy AT firstcomm DOT com = all, !skipped            
  operator = shandy AT firstcomm DOT com = mount
  console = all, !skipped, !saved
#
# WARNING! the following will create a file that you must cycle from
#          time to time as it will grow indefinitely. However, it will
#          also keep all your messages if they scroll off the console.
#
  append = "/var/lib/bacula/log" = all, !skipped
}


#
# Message delivery for daemon messages (no job).
Messages {
  Name = Daemon
  mailcommand = "/usr/lib/bacula/bsmtp -h 172.16.6.106  -f \"\(Bacula\) 
\<%r\>\" -s \"Bacula daemon message\" %r"
  mail = shandy AT firstcomm DOT com = all, !skipped            
  console = all, !skipped, !saved
  append = "/var/lib/bacula/log" = all, !skipped
}



    
# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days           # one year
  Maximum Volumes = 3 
  Maximum Volume Bytes = 200G
                  
}



# Windows File Server Pool
Pool {
  Name = Windows File Server Backup
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days           # one year
  Maximum Volumes = 3
  Maximum Volume Bytes = 200G

}


# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
  Name = baculavm-mon
  Password = "fcomm"
  CommandACL = status, .status
}
#
# Default  Bacula File Daemon Configuration file
#
#  For Bacula release 2.4.4 (01/03/09) -- Windows MVS
#
# There is not much to change here except perhaps the
# File daemon Name
#

#
# "Global" File daemon configuration specifications
#
FileDaemon {                            # this is me
  Name = vcenter1-fd
  FDport = 9102                # where we listen for the director
  WorkingDirectory = "C:\\Documents and Settings\\All Users\\Application 
Data\\Bacula\\Work"
  Pid Directory = "C:\\Documents and Settings\\All Users\\Application 
Data\\Bacula\\Work"
  Maximum Concurrent Jobs = 2
}

#
# List Directors who are permitted to contact this File daemon
#
Director {
  Name = baculavm-dir
  Password = "fcomm"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = baculavm-mon
  Password = "fcomm"
  Monitor = yes
}

# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = vcenter1-fd = all, !skipped, !restored
}
#
# Default Bacula Storage Daemon Configuration file
#
#  For Bacula release 2.4.4 (28 December 2008) -- solaris 5.10
#
# You may need to change the name of your tape drive
#   on the "Archive Device" directive in the Device
#   resource.  If you change the Name and/or the 
#   "Media Type" in the Device resource, please ensure
#   that dird.conf has corresponding changes.
#

Storage {                             # definition of myself
  Name = backup-sd
  SDAddress = 172.16.8.100
  SDPort = 9103                  # Director's port      
  WorkingDirectory = "/usr/local/bacula/working"
  Pid Directory = "/usr/local/bacula/bin/working"
  Maximum Concurrent Jobs = 20
}

#
# List Directors who are permitted to contact Storage daemon
#
Director {
  Name = backup-dir
  Password = "globalc0m"
}

Director {
  Name = baculavm-dir
  Password = "fcomm"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the storage daemon
#
Director {
  Name = backup-mon
  Password = "6cpgg/V8vTNSn5DnmeAINL4z+5O0GqqQVIR7r2lRHNya"
  Monitor = yes
}

Director {
  Name = baculavm-mon
  Password = "fcomm"
  Monitor = yes
}




#
# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
#  same Name and MediaType. 
#

#Device {
#  Name = FileStorage
#  Media Type = File
#  Archive Device = 
#  LabelMedia = yes;                   # lets Bacula label unlabeled media
#  Random Access = Yes;
#  AutomaticMount = yes;               # when device opened, read it
#  RemovableMedia = no;
#  AlwaysOpen = no;
#}

#
# An autochanger device with two drives
#
#Autochanger {
#  Name = Autochanger
#  Device = Drive-1
#  Device = Drive-2
#  Changer Command = "/home/kern/bacula/bin/mtx-changer %c %o %S %a %d"
#  Changer Device = /dev/sg0
#}

#
# An autochanger device with two drives
#
Autochanger {
  Name = Autochanger
  Device = Drive-1
  Device = Drive-2
  Changer Command = "/home/kern/bacula/bin/mtx-changer %c %o %S %a %d"
  Changer Device = /dev/scsi/changer/c6t5d0
}

#Device {
#  Name = Drive-1                      #
#  Drive Index = 0
#  Media Type = DLT-8000
#  Archive Device = /dev/nst0
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  AutoChanger = yes
#  #
#  # Enable the Alert command only if you have the mtx package loaded
#  # Note, apparently on some systems, tapeinfo resets the SCSI controller
#  #  thus if you turn this on, make sure it does not reset your SCSI 
#  #  controller.  I have never had any problems, and smartctl does
#  #  not seem to cause such problems.
#  #
#  Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

#Device {
#  Name = Drive-2                      #
#  Drive Index = 1
#  Media Type = DLT-8000
#  Archive Device = /dev/nst1
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  AutoChanger = yes
#  # Enable the Alert command only if you have the mtx package loaded
#  Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

#
# A Linux or Solaris tape drive
#
#Device {
#  Name = DDS-4                        # 
#  Media Type = DDS-4
#  Archive Device = /dev/rmt/0cbn
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
## Changer Command = "/usr/local/bacula/bin/mtx-changer %c %o %S %a %d"
## Changer Device = /dev/sg0
## AutoChanger = yes
#  # Enable the Alert command only if you have the mtx package loaded
## Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo 
## Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

#
# A Linux or Solaris tape drive
#
Device {
  Name = Drive-1                      # 
  Media Type = LTO-2
  Archive Device = /dev/rmt/4cbn
  AutomaticMount = yes;               # when device opened, read it
  AlwaysOpen = yes;
  RemovableMedia = yes;
  RandomAccess = no;
 Changer Command = "/usr/local/bacula/bin/mtx-changer %c %o %S %a %d"
 Changer Device = /dev/scsi/changer/c6t5d0
 AutoChanger = yes
 Offline On Unmount = Yes;
 Drive Index = 0;
  Spool Directory = "/mnt/database/testrestore"
  Maximum Spool Size = 200000000000
# Enable the Alert command only if you have the mtx package loaded
Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo 
## Alert Command = "sh -c 'smartctl -H -l error %c'"  
}

#
# A Linux or Solaris tape drive
#
Device {
  Name = Drive-2                      # 
  Media Type = LTO-2
  Archive Device = /dev/rmt/3cbn
  AutomaticMount = yes;               # when device opened, read it
  AlwaysOpen = yes; 
  RemovableMedia = yes;
  RandomAccess = no;
 Changer Command = "/usr/local/bacula/bin/mtx-changer %c %o %S %a %d"
 Changer Device = /dev/scsi/changer/c6t5d0
 AutoChanger = yes
 Offline On Unmount = Yes;
 Drive Index = 1;
  Spool Directory = "/mnt/database/testrestore"
  Maximum Spool Size = 200000000000
# Enable the Alert command only if you have the mtx package loaded
Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo 
## Alert Command = "sh -c 'smartctl -H -l error %c'"  
}

#
# A FreeBSD tape drive
#
#Device {
#  Name = DDS-4 
#  Description = "DDS-4 for FreeBSD"
#  Media Type = DDS-4
#  Archive Device = /dev/nsa1
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes
#  Offline On Unmount = no
#  Hardware End of Medium = no
#  BSF at EOM = yes
#  Backward Space Record = no
#  Fast Forward Space File = no
#  TWO EOF = yes
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

#
# A OnStream tape drive. 
# You need the kernel osst driver 0.9.14 or later, and
#   do "mt -f /dev/nosst0 defblksize 32768" once as root.
#
#Device {
#  Name = OnStream
#  Description = "OnStream drive on Linux"
#  Media Type = OnStream
#  Archive Device = /dev/rmt/0cbn
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = yes
#  Offline On Unmount = no
## The min/max blocksizes of 32768 are *required*
#  Minimum Block Size = 32768
#  Maximum Block Size = 32768
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}
 
#
# A DVD device
#
#Device {
#  Name = "DVD Writer"
#  Media Type = DVD
#  Device Type = DVD
#  Archive Device = /dev/hdc
#  LabelMedia = yes;                   # lets Bacula label unlabeled media
#  Random Access = Yes;
#  AutomaticMount = yes;               # when device opened, read it
#  RemovableMedia = yes;
#  AlwaysOpen = no;
#  MaximumPartSize = 800M;
#  RequiresMount = yes;
#  MountPoint = /mnt/cdrom;
#  MountCommand = "/bin/mount -t iso9660 -o ro %a %m";
#  UnmountCommand = "/bin/umount %m";
#  SpoolDirectory = /tmp/backup;
#  WritePartCommand = "/etc/bacula/dvd-handler %a write %e %v"
#  FreeSpaceCommand = "/etc/bacula/dvd-handler %a free"
#}

#
# For OpenBSD OS >= 3.6
#
#Device {
#  Name = DDS-3
#  Media Type = DDS-3
#  Archive Device = /dev/nrst0
#  Use MTIOCGET= no
#  BSF at EOM = yes
#  TWO EOF = no
#  AutomaticMount = yes;
#  AlwaysOpen = yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

#
# A very old Exabyte with no end of media detection
#
#Device {
#  Name = "Exabyte 8mm"
#  Media Type = "8mm"
#  Archive Device = /dev/rmt/0cbn
#  Hardware end of medium = No;
#  AutomaticMount = yes;               # when device opened, read it
#  AlwaysOpen = Yes;
#  RemovableMedia = yes;
#  RandomAccess = no;
#  If you have smartctl, enable this, it has more info than tapeinfo 
#  Alert Command = "sh -c 'smartctl -H -l error %c'"  
#}

# 
# Send all messages to the Director, 
# mount messages also are sent to the email address
#
Messages {
  Name = Standard
  director = backup-dir = all
}
#!/bin/sh
#
# Bacula interface to mtx autoloader
#
#  $Id: mtx-changer.in 7291 2008-07-02 20:49:44Z kerns $
#
#  If you set in your Device resource
#
#  Changer Command = "path-to-this-script/mtx-changer %c %o %S %a %d"
#    you will have the following input to this script:
#
#  So Bacula will always call with all the following arguments, even though
#    in come cases, not all are used.
#
#  mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
#                  $1              $2       $3        $4               $5
#
#  for example:
#
#  mtx-changer /dev/sg0 load 1 /dev/nst0 0 (on a Linux system)
# 
#  will request to load the first cartidge into drive 0, where
#   the SCSI control channel is /dev/sg0, and the read/write device
#   is /dev/nst0.
#
#  The commands are:
#      Command            Function
#      unload             unload a given slot
#      load               load a given slot
#      loaded             which slot is loaded?
#      list               list Volume names (requires barcode reader)
#      slots              how many slots total?
#
#  Slots are numbered from 1 ...
#  Drives are numbered from 0 ...
#
#
#  If you need to an offline, refer to the drive as $4
#    e.g.   mt -f $4 offline
#
#  Many changers need an offline after the unload. Also many
#   changers need a sleep 60 after the mtx load.
#
#  N.B. If you change the script, take care to return either 
#   the mtx exit code or a 0. If the script exits with a non-zero
#   exit code, Bacula will assume the request failed.
#

##echo $* > /tmp/f1

MTX=/usr/local/sbin/mtx

# mt status output
# SunOS     No Additional Sense
# FreeBSD   Current Driver State: at rest.
# Linux     ONLINE
#  Note Debian has a different mt than the standard Linux version. 
#    When no tape is in the drive it waits 2 minutes.  
#    When a tape is in the drive, it prints user unfriendly output.
#  Note, with Ubuntu Gusty (8.04), there are two versions of mt,
#    so we attempt to figure out which one.
#

OS=`uname`
case ${OS} in
  SunOS)
    ready="No Additional Sense"
    ;;
  FreeBSD)
    ready="Current Driver State: at rest."
    ;;
  Linux)
    ready="ONLINE"
    if test -f /etc/debian_version ; then
       mt --version|grep "mt-st" >/dev/null 2>&1
       if test $? -eq 1 ; then
          ready="drive status"
       fi
    fi
  ;;
esac

#
# log whats done
#
# to turn on logging, uncomment the following line
#touch /usr/local/bacula/working/mtx.log
#
dbgfile="/usr/local/bacula/working/mtx.log"
debug() {
    if test -f $dbgfile; then
        echo "`date +\"%Y%m%d-%H:%M:%S\"` $*" >> $dbgfile
    fi
}


#
# Create a temporary file
#
make_temp_file() {
  TMPFILE=`mktemp /usr/local/bacula/working/mtx.XXXXXXXXXX`
  if test x${TMPFILE} = x; then
     TMPFILE="/usr/local/bacula/working/mtx.$$"
     if test -f ${TMPFILE}; then
        echo "Temp file security problem on: ${TMPFILE}"
        exit 1
     fi
  fi
}

#
# The purpose of this function to wait a maximum 
#   time for the drive. It will
#   return as soon as the drive is ready, or after
#   waiting a maximum of 300 seconds.
# Note, this is very system dependent, so if you are
#   not running on Linux, you will probably need to
#   re-write it, or at least change the grep target.
#   We've attempted to get the appropriate OS grep targets
#   in the code at the top of this script.
#
wait_for_drive() {
  i=0 
  while [ $i -le 300 ]; do  # Wait max 300 seconds
    if mt -f $1 status 2>&1 | grep "${ready}" >/dev/null 2>&1; then
      break
    fi
    debug "Device $1 - not ready, retrying..."
    sleep 1
    i=`expr $i + 1`
  done
}

# check parameter count on commandline
#
check_parm_count() {
    pCount=$1
    pCountNeed=$2
    if test $pCount -lt $pCountNeed; then
        echo "usage: mtx-changer ctl-device command [slot archive-device 
drive-index]"
        echo "  Insufficient number of arguments given."
        if test $pCount -lt 2; then
            echo "  Mimimum usage is first two arguments ..."
        else
            echo "  Command expected $pCountNeed arguments"
        fi
        exit 1
    fi
}

# Check for special cases where only 2 arguments are needed, 
#  all others are a minimum of 5
#
case $2 in
    list)
        check_parm_count $# 2
        ;;
    slots)
        check_parm_count $# 2
        ;;
    *)
        check_parm_count $# 5
        ;;
esac


# Setup arguments
ctl=$1
cmd="$2"
slot=$3
device=$4
drive=$5

debug "Parms: $ctl $cmd $slot $device $drive"

case $cmd in 
   unload)
      debug "Doing mtx -f $ctl unload $slot $drive"
#
# enable the following line if you need to eject the cartridge
#     mt -f $device offline
#     sleep 10
      ${MTX} -f $ctl unload $slot $drive
      ;;

   load)
      debug "Doing mtx -f $ctl load $slot $drive"
      ${MTX} -f $ctl load $slot $drive
      rtn=$?
#
# Increase the sleep time if you have a slow device
# or remove the sleep and add the following:
#     sleep 15
      wait_for_drive $device
      exit $rtn
      ;;

   list) 
      debug "Doing mtx -f $ctl -- to list volumes"
      make_temp_file
# Enable the following if you are using barcodes and need an inventory
     ${MTX} -f $ctl inventory
      ${MTX} -f $ctl status >${TMPFILE}
      rtn=$?
      cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print \$3 
\$4}" | sed 's/Full.*:VolumeTag=//g'
#
# If you have a VXA PacketLoader and the above does not work, try
#  turning it off and enabling the following line.
#     cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | sed "s/ Storage 
Element //" | sed "s/Full :VolumeTag=//"
#
      cat ${TMPFILE} | grep "^Data Transfer Element [0-9]*:Full (Storage 
Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}'
      rm -f ${TMPFILE} >/dev/null 2>&1
      exit $rtn
      ;;

   loaded)
      debug "Doing mtx -f $ctl $drive -- to find what is loaded"
      make_temp_file
      ${MTX} -f $ctl status >${TMPFILE}
      rtn=$?
      cat ${TMPFILE} | grep "^Data Transfer Element $drive:Full" | awk "{print 
\$7}"
      cat ${TMPFILE} | grep "^Data Transfer Element $drive:Empty" | awk "{print 
0}"
      rm -f ${TMPFILE} >/dev/null 2>&1
      exit $rtn
      ;;

   slots)
      debug "Doing mtx -f $ctl -- to get count of slots"
      ${MTX} -f $ctl status | grep " *Storage Changer" | awk "{print \$5}"
      ;;
esac
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
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>
  • [Bacula-users] [Fwd: Here you go!!!!!!], Brian Debelius <=