Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Recovers current tape in to $data_location (directory) and logs activity to $log_location (file)
- # If an argument is given, this is the blocking factor
- cont_loop=""
- block_size="300"
- serial=$(tapeinfo -rf /dev/nst0 -mam | grep "User Medium Text Label:" | awk '{ print $NF }')
- log_location="/media/manual_tar.log"
- data_location="/media/vtape/manual_recovery/"
- count=0
- mkdir -p $data_location
- chmod 777 $data_location
- if [ $# -ge 1 ];
- then
- block_size="$1"
- fi
- echo "Rewinding ..."
- mt -f /dev/nst0 rewind
- echo -e "Recovery of tape $serial started" | tee -a $log_location;
- while true;
- do
- count=$(expr $count + 1)
- cont_loop=$(tail -n4 $log_location | egrep "^tar: At beginning of tape, quitting now$")
- if [ -z "$cont_loop" ];
- then
- echo "Tar session $count - $(date +"%D %k:%M") - $serial" | tee -a $log_location
- tar xvf /dev/nst0 -b $block_size -C $data_location 2>&1 | tee -a $log_location
- else
- echo -e "Recovery of tape $serial finished\n\n\n" | tee -a $log_location
- exit 0
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment