#!/usr/bin/sh
#
# Script: eject_tapes.sh
#
# Purpose: This script generates a daily report of cloned volumes in NetWorker
# to be sent offsite and of volumes that can be returned to the library
# from offsite.
#
#
#
FOOTER1="***Report run on system nsrha by user lgtoadm."
FOOTER2="***/nsr/scripts/eject_tapes.sh"
OUTFILE=eject_tapes.txt
TMPFILE=eject_tapes.tmp
LIBRARY="sl8500"
MAILTO="user name"
#
# Begin main
#
#
# Remove the temp file if it exists.
#
#[ -s $TMPFILE ] && rm $TMPFILE
#
# Eject any volumes not in use.
#
sudo nsrjb -j $LIBRARY -u
#
# Print header to file.
#
echo "Daily tapes to be sent offsite:" > $OUTFILE
echo "-------------------------------" >> $OUTFILE
#
# Create a list of clone pools.
#
sudo mminfo -r "pool" -q "clonetime > yesterday,location=$LIBRARY"|sort|uniq|grep -v Test|while read POOL
do
#
# For each clone pool, list any volumes to be sent offsite to a temp file.
#
sudo mminfo -r "volume" -q "clonetime > yesterday,%used>100,pool=$POOL,location=$LIBRARY, written > 0, near, !volrecycle, !inuse" >> $TMPFILE
done
#
# Process the list of volumes in the temp file to be sent offsite.
#
cat $TMPFILE|while read VOLUME
do
#
# Set the location of the volume.
#
sudo mmlocate -n $VOLUME -u "Offsite"
#
# Print the information of volumes to be sent offsite to the report.
#
sudo mminfo -r "volume,pool,location" -q "volume=$VOLUME"|grep -v volume >> $OUTFILE
#
# Set the volume as ReadOnly in case the volume is returned to the library before it is reusable.
#
sudo nsrmm -o readonly -y $VOLUME
#
# Eject the volume from the NetWorker database (ACSLS procedure).
#
sudo mmlocate -n $VOLUME -u "Offsite"
echo "Volume set Offsite" $VOLUME
sudo nsrjb -j $LIBRARY -x -T $VOLUME
done
#
# Print volume return header to report.
#
echo >> $OUTFILE
echo "Daily tapes to be Returned:" >> $OUTFILE
echo "---------------------------" >> $OUTFILE
#
# Print the list of volumes that are recyclable and can be returned from offsite.
#
sudo mminfo -r "volume,pool,location" -q "!near, volrecycle, !manual"|grep -v volume >> $OUTFILE
#
# Eject the volumes to be sent offsite from the STK silo to the cap (ACSLS procedure).
#
sudo stk_eject acsls01 0,1,0 nowait `cat $TMPFILE`
#
# Print the bootstrap information to the report to be sent offsite with the volumes.
#
#echo >> $OUTFILE
#echo "Bootstrap report to be kept offsite:" >> $OUTFILE
#echo "------------------------------------" >> $OUTFILE
#sudo mminfo -B >> $OUTFILE
#
# Print footer information to the report.
#
echo >> $OUTFILE
echo >> $OUTFILE
echo "$FOOTER1" >> $OUTFILE
echo "$FOOTER2" >> $OUTFILE
#
# Email the report.
#
mailx -s "NetWorker tapes to be sent offsite/returned" $MAILTO < $OUTFILE
#
# End main
$
We use this unix script which you can use a guide, we also have a sl8500, that is why we use the stk_eject command you can use the nsrjb -X command insted if you have a different silo. good luck