Some quick bash-script with basic tape operations:
#!/bin/bash
export TAPE="/dev/nst0"
############################################
function anykey {
read -n 1 -p "Press any key to continue..."
}
while true; do
clear
cat <<EOF
Choose action:
1. Show tape status
2. Show list of files of current block
3. Write new data (append tape)
4. Rewind tape (Set to BOT)
5. Wind tape (Set to EOD)
6. Set head to N blocks before
7. Set head to N blocks after
8. Extract data from current block
9. Erase tape
0. Exit
-----
EOF
read -p "Select action: " ans
case $ans in
1).
echo "====="; mt status ; echo "====="; anykey ;;
2)
echo "====="; tar tzv; echo "====="
echo "Rewinding to the beginning of current block..."
mt bsf 2; mt fsf
echo "Done"; anykey ;;
3).
read -p "Select file or directory: " path
cd $(dirname $path)
if [ $? -ne 0 ]; then
anykey
continue
fi..
echo "Positioning to the end of written data..."
mt eod; tar czv $(basename $path) -C $(dirname $path)
echo "Done"; anykey ;;
4).
echo "Rewinding tape..."; mt rewind; echo "Done"; anykey ;;
5).
echo "Winding tape..."; mt eod; echo "Done"; anykey ;;
6)
read -p "Enter number of blocks before to set to: " ans
mt bsf $(($ans+1)); mt fsf
echo "Done"; anykey ;;
7)
read -p "Enter number of blocks after to set to: " ans
mt fsf $ans; echo "Done"; anykey ;;
8)
read -p "Enter folder where to extract: " path
cd $path
if [ $? -ne 0 ]; then
anykey
continue
fi
read -p "Extract all data from this block? [Y|n]: " ans
if [ $ans == "n" ]; then
read -p "Enter file or dir name: " ans
tar zxpv $ans
else
tar zxpv
fi
echo "Done"; anykey ;;
9)
echo "WARNING! Erasing will destroy ALL data on tape! Continue? [y|n]"; read ans
if [ $ans == "y" ]; then
echo "Rewinding tape..."; mt rewind;.
echo "Erasing tape. This is quite long operation..."; mt erase; echo "Done"
fi
anykey ;;
0) exit 0 ;;
*) continue ;;
esac
done