Bacula-users

Re: [Bacula-users] Label Barcodes delete data?

2009-09-21 13:56:58
Subject: Re: [Bacula-users] Label Barcodes delete data?
From: Wolfgang Denk <wd AT denx DOT de>
To: John Drescher <drescherjm AT gmail DOT com>
Date: Mon, 21 Sep 2009 19:37:08 +0200
Dear John Drescher,

In message <387ee2020909210749o48d1fd07qd829c661ae7af7dd AT mail.gmail DOT com> 
you wrote:
>
> > I believe putting a barcode label on a tape that already has a manual
> > label will not delete the tape however executing the label barcode
> > command will fail because the tape already has a label in its bacula
> > header.
> 
> I do not know a the solution to this problem.
> 
> I would however over time recycle/delete the tapes with manual labels
> so that you can add proper barcode labels to all your volumes.

An alternative solution is a small modification to the "mtx" script to
allow mapping of barcode labels to arbitrary volume names. This is
working fine for me:

#
# Map barcode label into a more comprehensive volume name
#
# Input: "2:" or "4:ABC123" ==> Output: "2:" resp. "4:K-H-4"
#
# Slot: ${line%%:*}, Barcode: ${line##*:}
#
map_barcode() {
  while read line ; do
    if [ \! -r /etc/bacula/Barcodes.conf ] ; then
      echo "$line"
      continue
    fi
    if [ -z "${line##*:}" ] ; then
      echo "$line"
      continue
    fi
    echo "${line%%:*}:`grep "^${line##*:}" /etc/bacula/Barcodes.conf | sed -e 
"s/${line##*:}[    ][      ]*//"`"
  done
}

plus this tiny patch:

@@ -173,12 +193,12 @@
       fi
       ${MTX} -f $ctl status >${TMPFILE}
       rtn=$?
-      if test ${vxa_packetloader} -ne 0 ; then
-       cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | sed "s/ 
Storage Element //" | sed "s/Full :VolumeTag=//"
-      else
-       cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print 
\$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
-      fi
-      cat ${TMPFILE} | grep "^Data Transfer Element [0-9]*:Full (Storage 
Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}'
+      { grep ' *Storage Element [0-9]*:.*Full' <${TMPFILE} | \
+               awk '{print $3 $4}' | \
+               sed 's/Full *\(:VolumeTag=\)*//'
+       grep '^Data Transfer Element [0-9]*:Full (Storage Element [0-9]' 
<${TMPFILE} | \
+               awk '{printf "%s:%s\n",$7,$10}'
+      } | map_barcode

My "/etc/bacula/Barcodes.conf" looks something like that:

Barcode VolumeID
======= ========
ABV101  I-001
ABV102  I-002
ABV103  I-003
ABV104  I-004
ABV105  I-005
ABV106  I-006
...



Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd AT denx DOT de
An expert is a person who avoids the small errors while  sweeping  on
to the grand fallacy.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users