磁带备份 HP Ultrium 460

磁带备份 HP Ultrium 460

有一个 subj 磁带驱动器(LTO-2 磁带,SCSI 连接)连接到 Debian 8。我不明白它是否可以进行“会话”写入?如果是的话,必须如何正确地完成?

我的意思是,我需要somedir1在磁带上写入一次,然后一段时间后,somedir2在同一磁带上写入,并且磁带设备必须“附加”somedir2到磁带上已写入的数据。诸如多区段写入 CD/DVD 之类的东西。

因为现在我找不到创建任何“会话”的方法。

我是如何写作的:

mt -f /dev/st0 eod- 将磁带设置到数据末尾

tar -czf /dev/st0 /somedir1- 写作somedir1

mt -f /dev/st0 eod- 再次将磁带设置到数据末尾(导致磁带设备倒带)

tar -czf /dev/st0 /somedir2- 写作somedir2

mt -f /dev/st0 rewind- 倒带。

然后,当用它读取数据时,tar -tzf /dev/st0仅列出somedir2,而不列出somedir1

答案1

关于磁带备份的一些注意事项。也许有人觉得它有用......

  1. 写入后不要倒带 - 使用/dev/nst0设备(对于 Linux)
  2. 设置 shell 变量TAPE=/dev/nst0
  3. 将磁头设置到磁带的开头:mt rewind
  4. 将 head 设置为写入磁带数据块的末尾:mt eod
  5. 获取当前磁带位置:mt status并查看File numberblock number
  6. 将磁带头设置为前一个块的开头:mt bsf 2; mt fsf。不要使用将磁头设置到磁带开头 - 使用倒带
  7. tar czv <dir_or_file>- 写入<dir_or_file>磁带
  8. tar tzv- 获取磁带上当前数据块的内容(文件列表)。
  9. 有时会发生错误 - 用于mt retension重置软错误

一些带有基本磁带操作的快速 bash 脚本:

#!/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

磁带驱动器设备

答案2

你需要使用/dev/nst0;/dev/st0当设备关闭时倒带,/dev/nst0不倒带。在当前的工作流程中,您总是写入磁带的开头......

您可能还想查看胶带标记(请参阅mt文档)。

相关内容