#!/bin/sh # tape-list # Read configuration informations source /etc/backup.conf print_usage() { echo "$(basename $0) - List content of tape archive." echo "Usage: $(basename $0) [-h] [--label]" } if [ ${#} -gt 0 ]; then if [ "x${1}" = "x-h" ]; then print_usage exit 0 fi fi if [ $# -gt 1 ]; then print_usage exit 1 fi if [ $# = 1 ]; then if [ "x${1}" != "x--label" ]; then echo "Invalid argument" print_usage exit 1 fi print_label="1" fi if ${MT} status | grep "ONLINE" 1> /dev/null 2>&1; then # Rewinding the tape ${MT} rewind || exit 1 file="0" quit="0" while [ ${quit} = "0" ]; do file="$(( ${file} + 1 ))" if [ "x${print_label}" = "x1" ]; then echo "Label for archive #$file:" tar tvf /dev/tape | grep "V---------" if [ $? -ne 0 ]; then echo "No archive #$file:" quit="1" fi else echo "Content of archive #$file:" tar tvf /dev/tape || exit 1 fi if [ ${quit} = "0" ]; then # Position tape on next file ${MT} fsf 1 if [ $? -ne 0 ]; then quit="1" fi fi done else echo "TAPE DRIVE IS OFFLINE, NO LISTING PERFORMED" exit 1 fi exit $?