Bacula-users

Re: [Bacula-users] Non-bacula: Tar restore in an autochanger

2011-07-25 15:56:00
Subject: Re: [Bacula-users] Non-bacula: Tar restore in an autochanger
From: Dan Langille <dan AT langille DOT org>
To: Alan Brown <ajb2 AT mssl.ucl.ac DOT uk>
Date: Mon, 25 Jul 2011 15:53:31 -0400
On Jul 25, 2011, at 12:37 PM, Alan Brown wrote:

> I've been handed a tar backup comprising 66 (yes really) LTO4 tapes.
> 
> For obvious reasons I'd prefer not to have to load the tape drive 
> manually for each tape. Does anyone have pointers (or even better a 
> script) on automating this kind of restore?


I'm sorry Alan...

I have no idea how to detect that tar needs the next volume, but I do have
a script that loads each tape in turn.  It was designed for wiping the tapes, 
but I hope it's useful to you.

[dan@kraken:~/bin] $ cat erase-tapes.sh 
#!/bin/sh
#
# Copyright 2006 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
#
MTXCHANGER="/usr/local/sbin/mtx-changer"

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

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

echo things
echo "${MTXCHANGER} ${CHANGER} list ${DRIVE}"
echo

SLOTS=`${MTXCHANGER} ${CHANGER} list`

for slot_vol in $SLOTS
do
        slot=`echo ${slot_vol} | sed -ne 's/^\([0-9]*\):.*/\1/p'`
        vol=`echo ${slot_vol} | sed -ne 's/^[0-9]*:\(.*\)/\1/p'`
        ${ECHO} loading $slot
        ${MTXCHANGER} ${CHANGER} load $slot ${DRIVE} 0
        
        sleep 60

        mt -f ${DRIVE} rewind
        mt -f ${DRIVE} weof
        mt -f ${DRIVE} rewind

        echo "label storage=DigitalTapeLibrary volume=${vol} slot=${slot} 
pool=Scratch" | bconsole
        echo 'umount storage=DigitalTapeLibrary' | bconsole
        
        ${ECHO} unloading $slot
        ${MTXCHANGER} ${CHANGER} unload $slot ${DRIVE} 0
done


-- 
Dan Langille - http://langille.org


------------------------------------------------------------------------------
Storage Efficiency Calculator
This modeling tool is based on patent-pending intellectual property that
has been used successfully in hundreds of IBM storage optimization engage-
ments, worldwide.  Store less, Store more with what you own, Move data to 
the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users