Advertisement
1823alex

SimpleBackup.sh

May 24th, 2024
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.32 KB | None | 0 0
  1. #!/bin/bash
  2. #Alex's simple multi tape backup script
  3.  
  4. read -p "Enter tape path (st0/st1): " tapepath
  5. echo $tapepath
  6. # Prompt user for directory
  7. read -p "Enter the directory path to archive: " directory
  8. echo $directory
  9. # Check if directory exists
  10. if [ ! -d "$directory" ]; then
  11.   echo "Error: Directory not found."
  12.   exit 1
  13. fi
  14.  
  15. # Prompt user for tape label
  16. read -p "Enter tape label: " tape_label
  17.  
  18.  
  19.  
  20. # Create multi-volume tar archive
  21. echo "Creating multi-volume tape archive..."
  22. tar -b 4096 --directory="$directory" --multi-volume --label="$tape_label" -cf - ./ | mbuffer -m 6G -L -P 80 -f -o /dev/st0
  23. #Previous tar command iterations/configs
  24. #tar clpMvf - $directory -V $tape_label | mbuffer -m 4g -L -P 80 > /dev/st0
  25. #tar -M -c -v -f /dev/st0 -L 1024 -b 20 --label="$tape_label" "$directory" | \
  26.  
  27. while IFS= read -r line; do
  28.   #this might not work ^ - feel free to expand/add your own detection and automation for tape loading
  29.   # Check if the output line indicates a tape change request
  30.   if [[ "$line" == *"Please insert volume"* ]]; then
  31.     echo "Tape change requested..."
  32.   fi
  33.   echo "$line"
  34. done
  35.  
  36. # Check if tar command was successful
  37. if [ $? -eq 0 ]; then
  38.   echo "Multi-volume tape archive creation successful."
  39. else
  40.   echo "Error: Failed to create multi-volume tape archive."
  41.   exit 1
  42. fi
  43.  
  44. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement