]> git.sur5r.net Git - bacula/bacula/commitdiff
Update doc
authorKern Sibbald <kern@sibbald.com>
Sun, 25 Apr 2004 08:21:35 +0000 (08:21 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 25 Apr 2004 08:21:35 +0000 (08:21 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1299 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/examples/autochangers/chio-changer.Sony-TSL-SA300C [new file with mode: 0755]
bacula/examples/autochangers/mtx-changer.Sony-TSL-SA300C [new file with mode: 0755]
bacula/src/dird/sql_cmds.c

diff --git a/bacula/examples/autochangers/chio-changer.Sony-TSL-SA300C b/bacula/examples/autochangers/chio-changer.Sony-TSL-SA300C
new file mode 100755 (executable)
index 0000000..206f508
--- /dev/null
@@ -0,0 +1,151 @@
+#!/bin/sh
+#
+# Bacula interface to mtx autoloader
+# (By Lars Köller, lars+bacula@koellers.net)
+#
+# Modified by Jesse D. Guardiani (jesse@wingnet.net) in Feb 2004
+# to be more error resistant and compatible with my 4 tape SONY
+# AIT-1 TSL-SA300C autoloader.
+#
+#  If you set in your Device resource
+#
+#  Changer Command = "path-to-this-script/chio-bacula" %c %o %S %a
+#    you will have the following input to this script:
+#
+#  chio-bacula "changer-device" "command" "slot" "archive-device"
+#
+#  for example:
+#
+#  chio-bacula /dev/ch0 load 1 /dev/nst0 (on a FreeBSD system)
+#
+#  If you need to to an offline, refer to the drive as $4
+#    e.g.   mt -f $f 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.
+#
+
+# This simulates a barcode reader in the changer.
+# The labes of the virtual barcode reader are located in the BARCODE_FILE
+SIMULATE_BARCODE=true
+BARCODE_FILE=/usr/local/etc/bacula-barcodes
+
+me=$(basename $0)
+fullpath_me=$0
+
+# Debug
+logger -p user.err "$fullpath_me $@"
+
+if [ -z "$1" ] ; then
+    usage;
+fi
+
+if [ -z "$2" ] ; then
+    usage;
+fi
+
+MTX=/bin/chio
+CHANGER=$1
+COMMAND=$2
+if [ ! -z "$3" ]; then
+    SLOT=$3
+fi
+if [ ! -z "$4" ]; then
+    TAPE=$4
+else
+    TAPE=/dev/nrsa1
+fi
+
+# Time to wait for loading
+SLEEP=20
+# What drive of the autochanger should be used primary
+# At the moment bacula (1.31a) could not deal with more than one drive
+DRIVE=0
+
+usage()
+{
+  echo ""
+  echo "The $me script for bacula"
+  echo "--------------------------------------"
+  echo ""
+  echo "usage: $me <changer-device> <command> [slot] [devicename of tapedrive]"
+  echo ""
+  echo "Valid commands:"
+  echo ""
+  echo "unload          Unloads a tape into the slot"
+  echo "                from where it was loaded."
+  echo "load <slot>     Loads a tape from the slot <slot>"
+  echo "                (slot-base is calculated to 1 as first slot)"
+  echo "list            Lists full storage slots"
+  echo "loaded          Gives slot from where the tape was loaded."
+  echo "                0 means the tape drive is empty."
+  echo "slots           Gives Number of aviable slots."
+  echo ""
+  echo "Example:"
+  echo "  mtx-changer /dev/changer load 1   loads a tape from slot 1"
+  echo ""
+  exit 2
+}
+
+
+case ${COMMAND} in
+    unload)
+       # enable the following line if you need to eject the cartridge
+       #mt -f ${TAPE} off
+       #sleep 2
+       # If the changer is power cycled with a tape loaded in a drive
+       if [ `${fullpath_me} ${CHANGER} loaded` -gt 0 ]; then
+               free_slot=`${fullpath_me} ${CHANGER} loaded`
+               free_slot=`expr $free_slot - 1`
+               ${MTX} -f ${CHANGER} move drive ${DRIVE} slot $free_slot
+       fi
+       ;;
+
+    load)
+       ${MTX} -f ${CHANGER} move slot $((${SLOT}-1)) drive ${DRIVE}
+       rtn=$?
+       # Increase the sleep time if you have a slow device
+       sleep $SLEEP
+       exit $rtn
+       ;;
+
+    list)
+       if [ "${SIMULATE_BARCODE}" = "true" ]; then
+           if [ -f "$BARCODE_FILE" ]; then
+               cat $BARCODE_FILE | grep -v "^#"
+               exit 0
+           else
+               echo "Barcode file $BARCODE_FILE missing ... exiting!"
+               exit 1
+           fi
+       else
+           ${MTX} -f ${CHANGER} status | grep "^slot .*: .*FULL>" | awk '{print $2}' | awk -F: '{print $1+1" "}' | tr -d "[\r\n]"
+       fi
+      ;;
+
+    loaded)
+       # echo "Request loaded"
+       ${MTX} -f ${CHANGER} status -S > /tmp/mtx.$$
+       rtn=$?
+       cat /tmp/mtx.$$ | grep "^slot .: <ACCESS>" | awk '{print $2+1}' | tr -d ":"
+       drive=`cat /tmp/mtx.$$ | grep "^drive .: <ACCESS>"`
+       if [ -n "$drive" ]; then
+               echo 0
+       fi
+       rm -f /tmp/mtx.$$
+       exit $rtn
+       ;;
+
+    slots)
+       # echo "Request slots"
+       ${MTX} -f ${CHANGER} status | grep "^slot " | tail -1 | awk '{print $2+1}' | tr -d ":"
+      ;;
+
+    *)
+       usage
+      ;;
+esac
diff --git a/bacula/examples/autochangers/mtx-changer.Sony-TSL-SA300C b/bacula/examples/autochangers/mtx-changer.Sony-TSL-SA300C
new file mode 100755 (executable)
index 0000000..ef4783d
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Bacula interface to mtx autoloader
+#
+#  This mtx-changer script was contributed by Fryderyk Wlostowski.
+#    It works with a Sony TLS-11000 changer, which needs
+#     the slot number to do an unload
+#
+#  mtx-changer "changer-device" "command" "slot"
+#
+#
+MTX=/opt/mtx1.2.17/sbin/mtx
+case "$2" in 
+   unload)
+#     echo "Doing mtx -f $1 $2"
+      NR_KASETY=`$MTX -f $1 status | grep "Empty" | tr " "  "~" | tr ":"  "~" | cut -d "~" -f 9`
+      $MTX -f $1 $2 $NR_KASETY
+      ;;
+
+   load)
+#     echo "Doing mtx -f $1 $2 $3"
+      $MTX -f $1 $2 $3
+      ;;
+
+   list) 
+#     echo "Requested list"
+      $MTX -f $1 status | grep "^[     ]*Storage Element [0-9]*:.*Full" | awk "{print \$3}" | sed "s/:.*$/ /g" | tr -d "[\r\n]"
+      ;;
+
+   loaded)
+#     echo "Request loaded"
+      $MTX -f $1 status | grep "Empty" | tr " " "~" | tr ":" "~" | cut -d "~" -f 9
+      echo 0
+      ;;
+
+   slots)
+#     echo "Request slots"
+      $MTX -f $1 status | grep "[  ]Storage Changer" | awk "{print \$5}"
+      ;;
+esac
index 6ba94f151c74fff24151f074d3d1b5d9ef9ea1ca..b3d3aa74a2444aba84b03dbcda2917aed505b976 100644 (file)
@@ -176,6 +176,10 @@ char *uar_file =
 #endif
 
 
+/*
+ * Find all files for a particular JobId and insert them into
+ *  the tree during a restore.
+ */
 char *uar_sel_files = 
    "SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat "
    "FROM File,Filename,Path "
@@ -298,7 +302,10 @@ char *uar_mediatype =
    "SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%u "
    "AND JobMedia.MediaId=Media.MediaId";
 
-/* Find JobId, FileIndex for a given path/file and date */
+/* 
+ *  Find JobId, FileIndex for a given path/file and date   
+ *  for use when inserting individual files into the tree.
+ */
 char *uar_jobid_fileindex = 
    "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
    "WHERE Job.JobId=File.JobId "