#!/bin/bash if [[ $(id -u) -ne 0 ]]; then echo "This script must be run as root" exit 1 fi OWNER=yourusername TMP_LISTING=/home/$OWNER/tapes/.new.txt NEW_LISTING=/home/$OWNER/tapes/new.txt for arg; do echo echo '---- Start:' $(date); mt -f /dev/nst0 status; mt -f /dev/nst0 status | grep File >> $NEW_LISTING; sg_logs /dev/nst0 -p tc_; du "$arg" && tar --index-file=$TMP_LISTING --blocking-factor=512 -cvvf - "$arg" | \ mbuffer -m 10G -L -P 80 | \ dd of=/dev/nst0 bs=256K iflag=fullblock; cat $TMP_LISTING >> $NEW_LISTING && rm $TMP_LISTING echo '---- End:' $(date); done; echo echo '===== End all =====' $(date); mt -f /dev/nst0 status; sg_logs /dev/nst0 -p tc_; chown $OWNER:$OWNER $NEW_LISTING echo echo "File index created: $NEW_LISTING" echo