May 272011
 

I have been using Bacula since 2004. I started off on DDS tapes, then moved to DLT. Now I’m backing up to a ZFS array and the copying to tape.

About a year ago, I obtained about 200 DLT tapes from a friend. They were no longer used at his place of work. He used Bacula and had written lots of 1s and 0s to the tapes to erase them. However, they still contained a Bacula label.

In order for me to use them, I needed to erase that label, add my own, and go from there.

Based upon an existing script I had, I wrote this script. With this, I can insert ten new tapes, add an external barcode label, put the mazagine in the tape library, and in 30 minutes, have 10 new volumes.

NOTE: the following script will destroy any data on all tapes in your magazine.

#!/bin/sh
#
# Copyright 2006-2011 Dan Langille
#
# This script should be read in conjunction with
# http://www.freebsddiary.org/tape-testing.php
#

# Change this to the location of your script
#
MTX="/usr/local/sbin/mtx-changer"

CHANGER="/dev/${1}"
DRIVE="/dev/${2}"

LOGGER=/usr/bin/logger
ECHO=/bin/echo

SLOTS="1 2 3 4 5 6 7 8 9 10"

for slot in $SLOTS
do
	${ECHO} loading $slot
	${MTX} ${CHANGER} load $slot ${DRIVE} 0

	mt -f ${DRIVE} rewind
	mt -f ${DRIVE} weof
	mt -f ${DRIVE} rewind
	
	# now label that slot
	echo | bconsole <<EOF
label barcodes pool=Scratch storage=DigitalTapeLibrary slot=${slot}
yes
EOF

	echo 'umount storage=DigitalTapeLibrary' | bconsole
done

To run this script, I issue this command:

time sudo sh ~/bin/EraseTapeLabels pass11 sa0

where

  1. time – tells me how long the rest of the command takes
  2. sudo – I am running this as non-root; sudo makes me root
  3. pass11 – my tape changer
  4. sa0 – the tape drive

As I type this, I can see room for improvement:

  1. Use nsa0, not sa0
  2. Supply the storage name as a parameter (DigitalTapeLibrary)
  3. Supply the list of slots as a parameter

Enjoy.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive