1

There's subj tape drive (LTO-2 tapes, SCSI connection) connected to Debian 8. And I can't understand if it can make "session" writes? And, if yes, how correctly it has to be done?

I mean, that I need to write somedir1 on tape once, then, after time, write somedir2 on same tape and tape device have to "append" somedir2 to already written data on tape. Something like multisessions writes on CD/DVD.

'Cause now I can't find a way to create any "sessions".

How I am writing:

mt -f /dev/st0 eod - setting tape to the end of data

tar -czf /dev/st0 /somedir1 - writing somedir1

mt -f /dev/st0 eod - setting tape to the end of data again (cause tape device rewinds tape)

tar -czf /dev/st0 /somedir2 - writing somedir2

mt -f /dev/st0 rewind - rewinding tape.

Then, when reading data with tar -tzf /dev/st0 it only lists somedir2, but not somedir1.

2 Answers 2

3

Some notes about tape backup. Maybe somebody finds it useful...

  1. Do not rewind tape after writing - use /dev/nst0 device (in case of linux)
  2. Set shell variable TAPE=/dev/nst0
  3. Set head to the beginnig of tape: mt rewind
  4. Set head to the end of written on tape data blocks: mt eod
  5. Get current tape postion: mt status and see File number and block number values
  6. Set tape head to the beginnig of previous block: mt bsf 2; mt fsf. Do not use to set head to the tape beginning - use rewind
  7. tar czv <dir_or_file> - write <dir_or_file> to tape
  8. tar tzv - get content of current block of data on tape (filelist).
  9. Sometimes errors occurs - use mt retension to reset soft errors

Some quick bash-script with basic tape operations:

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

Tape drive devices

2

You need to use /dev/nst0; /dev/st0 rewinds when the device is closed, /dev/nst0 doesn't. With your current workflow, you're always writing to the beginning of the tape...

You might also want to look into tape markers (see the mt documentation).

1
  • Thanks a lot. I'll try using /dev/nst0 Commented Nov 11, 2016 at 13:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.