Linux Tape Backup: Difference between revisions

From Dave-Wiki
Jump to navigation Jump to search
Line 59: Line 59:
File numbers start at zero (0).
File numbers start at zero (0).


===Write Directory To Tape, At Current Position===
===Write directory to blank tape===


<code>tar cvf /dev/nst0 {directory}</code>
Make sure you are at the beginning of the tape


or, you can also write the file list to a file so you have a record of files:
<code>mt -f /dev/nst0 rewind</code>
 
Write directory to tape


<code>tar cvf /dev/nst0 {directory} | tee {listing.txt}</code>
<code>tar -C /mnt/hdd/backup/vm-backup/ -c -v -f /dev/nst0 . | tee /mnt/hdd/backup/tape/240-0.txt</code>


===Rewind The Tape===
===Rewind The Tape===
Line 75: Line 77:
Make sure you move to the tar file you want, first
Make sure you move to the tar file you want, first


<code>tar tf /dev/nst0</code>
<code>tar tvf /dev/nst0</code>


or, you can also write the file list to a file so you have a record of files:
or, you can also write the file list to a file so you have a record of files:


<code>tar tf /dev/nst0 | tee {listing.txt}</code>
<code>tar tvf /dev/nst0 | tee {listing.txt}</code>

Revision as of 22:22, 1 June 2024

Linux Drivers

LSI SAS2008

LSI SAS 9200-8e 6Gbs PCI Express SAS Host Bus Adapter

My first obstacle was getting the drive to show up in Linux. Apparently RHEL/CentOS decided to stop putting LSI SAS2008 drivers in the distro, starting with RHEL/CentOS8. Here's some more info: https://access.redhat.com/discussions/3722151 Also a helpful vid: https://www.youtube.com/watch?v=4fOAuXiynYM

I was able to get the correct drivers for my LSI SAS2008 using the driver that matched my kernel (CentOS Stream 8/4.18.0-448.el8.x86_6) here: http://mirror.centos.org/centos/8-stream/kmods/x86_64/packages-rebuild/Packages/k/ (I used kmod-mlx4-4.18.0~448-1.el8s.x86_64.rpm).

Also, FWIW, I'm using a Quantum Ultrium LTO 4 (Model B) SAS Tape Drive attached to the LSI SAS9200-8e. I'm using a fresh install of CentOS Stream 8 on a Dell PowerEdge R730xd.

LSI SAS3008

Dell 12Gbps HBA / LSI SAS 9300-8e 12Gbs PCI Express SAS Host Bus Adapter

I have since switched to a LSI SAS3008 PCI-Express Fusion-MPT SAS-3 (branded as a Dell 0T93GD 12G SAS Low Profile Dual Port HBA) and the card just worked out of the box with RHEL 9.3 (it is using the built-in mpt3sas kernel driver). I'm still using the Quantum Ultrium LTO 4 (Model B) SAS Tape Drive, mounted in a 2U Dell PowerVault 114X enclosure.

Using The Tape Drive In Linux

The main program we will use is called mt. You can install it with sudo yum install mt-st (or equivalent command for your distro).

Device Names

The device name you utilize affects behavior after command executions:

/dev/st0
rewinds tape after being written to
/dev/nst0
don't rewind tape after being written to

More info: https://forums.fedoraforum.org/showthread.php?59746-SCSI-Tape-Drive

Operations

Check if tape is online

mt -f /dev/st0 status

A cartridge is inserted and ready to write. Because we used /dev/st0, the tape rewound itself after executing the command, and is now positioned at the beginning.

Check usage and capacity of a tape

sg_logs -a /dev/nst0 | grep -E "native\ capacity"

List The First file

file - < /dev/nst0

Example Output: blah

Forward Tape To Next File

mt -f /dev/nst0 fsf 1

Seek To A File On The Tape

mt -f /dev/nst0 asf {file_number}

File numbers start at zero (0).

Write directory to blank tape

Make sure you are at the beginning of the tape

mt -f /dev/nst0 rewind

Write directory to tape

tar -C /mnt/hdd/backup/vm-backup/ -c -v -f /dev/nst0 . | tee /mnt/hdd/backup/tape/240-0.txt

Rewind The Tape

mt -f /dev/nst0 rewind

List The Files In The Current Tar File

Make sure you move to the tar file you want, first

tar tvf /dev/nst0

or, you can also write the file list to a file so you have a record of files:

tar tvf /dev/nst0 | tee {listing.txt}