jaedaen

mr - tape manual recovery - Cache-A system script

Feb 22nd, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.02 KB | None | 0 0
  1. #!/bin/bash
  2. # Recovers current tape in to $data_location (directory) and logs activity to $log_location (file)
  3. # If an argument is given, this is the blocking factor
  4.  
  5. cont_loop=""
  6. block_size="300"
  7. serial=$(tapeinfo -rf /dev/nst0 -mam | grep "User Medium Text Label:" | awk '{ print $NF }')
  8. log_location="/media/manual_tar.log"
  9. data_location="/media/vtape/manual_recovery/"
  10. count=0
  11.  
  12. mkdir -p $data_location
  13. chmod 777 $data_location
  14.  
  15. if [ $# -ge 1 ];
  16. then
  17.     block_size="$1"
  18. fi
  19.  
  20. echo "Rewinding ..."
  21. mt -f /dev/nst0 rewind
  22.  
  23. echo -e "Recovery of tape $serial started" | tee -a $log_location;
  24.  
  25. while true;
  26. do
  27.     count=$(expr $count + 1)
  28.     cont_loop=$(tail -n4 $log_location | egrep "^tar: At beginning of tape, quitting now$")
  29.     if [ -z "$cont_loop" ];
  30.     then
  31.         echo "Tar session $count - $(date +"%D %k:%M") - $serial" | tee -a $log_location
  32.         tar xvf /dev/nst0 -b $block_size -C $data_location 2>&1 | tee -a $log_location
  33.     else
  34.         echo -e "Recovery of tape $serial finished\n\n\n" | tee -a $log_location
  35.         exit 0
  36.     fi
  37. done
Advertisement
Add Comment
Please, Sign In to add comment