16 Practical Linux/unix Tape Management commands

Source: Internet
Author: User
Tags rewind

In this tutorial you will learn:
· Tape Device Name
· Basic commands for managing tape drives
· Basic Backup and Restore commands
Why backup?
A backup plan is necessary for regular backup files, and if you prefer not to back up, the risk of losing important data increases significantly. With backup, you have the ability to recover from a disk failure. Backups can also help you protect against:
· Accidental file deletion
· file or file system corruption
· The server is completely destroyed, including a backup of the same disk caused by a fire or other problem
· Hard disk or SSD crashes
· Virus or ransomware destroys or deletes files
You can use tape archives to back up your entire server and store it offline.
Understanding tape File markers and block sizes
Each tape device can store multiple backup files. Tape backup files are created through commands such as CPIO,TAR,DD. At the same time, tape devices can be opened, written, and closed by a variety of programs. You can store several backups (tape files) onto a physical tape. There is a "tape file mark" between each tape file. This is used to indicate the end of a tape file on a physical tape and the beginning of another file. You need to use the MT command to locate the tape (fast forward, rewind, and Mark).

How the data on the tape is stored

All data is stored continuously in a continuous tape storage format using TAR. The first tape archive begins storage (tar #0) from the physical start of the tape. The next step is the tar #1, and so on.
Tape Device name on Unix
/dev/rmt/0 or/DEV/RMT/1 or/dev/rmt/[0-127]: A generic tape device name on Unix. The tape is automatically inverted back.
/dev/rmt/0n: Feature with no rewind, in other words, after the tape is used, stay in the current state and wait for the next command.
/DEV/RMT/0B: Using the tape interface, which is BSD behavior. The behavior of various types of operating systems, such as AIX,WINDOWS,LINUX,FREEBSD, is more readable.
/DEV/RMT/0L: Set the density to low.
/dev/rmt/0m: Set density to medium.
/DEV/RMT/0U: Set the density to high.
/DEV/RMT/0C: Set density to compression.
/DEV/ST[0-9]: Linux specific SCSI tape device name.
/DEV/SA[0-9]: FreeBSD specific SCSI tape device name.
/dev/esa0:freebsd a specific SCSI tape device name, which pops up when it is turned off (if available).
Tape Device Name Example
/DEV/RMT/1CN indicates that Unity 1 is being used, compression density, no rewind.
/DEV/RMT/0HB indicates that unity 0, high density, BSD behavior is being used.
Auto-Rewind SCSI tape device name on Linux:/dev/st0
Non-inverted SCSI tape device name on Linux:/dev/nst0
Auto-Rewind SCSI tape device on FreeBSD name:/dev/sa0
Non-inverted SCSI tape device name on FreeBSD:/dev/nsa0
How do I list the installed SCSI tape devices?
Enter the following command:
# # # Linux (more information see MAN) # # #
Lsscsi
Lsscsi-g
# # # IBM AIX # # #
LSDEV-CC Tape
LSDEV-CC ADSM
LSCFG-VL rmt*
# # # Solaris Unix # # #
Cfgadm–a
Cfgadm-al
Luxadm probe
Iostat-en
# # HP-UX Unix # # #
Ioscan Cf
Ioscan-func Tape
IOSCAN-FNC Tape
IOSCAN-KFC Tape
MT Command Example
On Linux and Unix-like systems, the MT command is used to control the operation of a tape drive, such as viewing a state or finding a file on a tape or writing a tape control tag. Most of the following commands need to be performed as root users. The syntax is as follows:
Mt-f/tape/device/name operation
Setting up the environment
You can set the TAPE shell variable. This is the path name of the tape drive. The default on FreeBSD (if the variable is not set, NOT null) is/DEV/NSA0. You can override this by passing a variable through the-f parameter of the MT command, as explained below.
# # # Add to your shell config file # # #
Tape=/dev/st1 #Linux
TAPE=/DEV/RMT/2 #Unix
TAPE=/DEV/NSA3 #FreeBSD
Export TAPE
1: Show tape/drive status
Mt Status # # # Use Default
Mt-f/dev/rmt/0 Status # # Unix
Mt-f/dev/st0 Status # # Linux
Mt-f/dev/nsa0 Status # # FreeBSD
Mt-f/DEV/RMT/1 Status # # Unix Unity 1 That's tape device No. 1
You can use the Shell Loop statement to traverse a system and locate all of its tape drives as follows:
For d in 0 1 2 3 4 5
Do
Mt-f "/dev/rmt/${d}" status
Done
2: Rewind
Mt Rew
Mt Rewind
Mt-f/dev/mt/0 Rewind
Mt-f/dev/st0 Rewind
3: Eject Tape
Mt off
Mt offline
Mt Eject
Mt-f/dev/mt/0 off
Mt-f/dev/st0 Eject
4: Erase tape (rewind, unload tape in case of support)
Mt Erase
Mt-f/dev/st0 Erase #Linux
Mt-f/dev/rmt/0 Erase #Unix
5: Tension Tape Box
If an error occurs while the tape is reading, you re-tighten the tape, clean the tape drive, and try again as follows:
Mt Retension
Mt-f/DEV/RMT/1 retension #Unix
Mt-f/dev/st0 retension #Linux

6: Write the EOF tag at the current position of the tape
Mt EOF
Mt Weof
Mt-f/dev/st0 EOF
7: Forward the tape to the specified number of file tokens, that is, skipping the specified EOF mark
The tape is positioned in the first block of the next file, i.e. the tape locates the first block in the next area (see Figure 01):
Mt FSF
Mt-f/dev/rmt/0 FSF
Mt-f/DEV/RMT/1 FSF 1 #go 1 forward file/tape (see fig.01)
8: Rewind tape To specify the number of file markers, that is, rewind with a specified EOF marker
The tape is positioned in the first block of the next file, i.e. the tape is positioned after the EOF tag (see figure 01):
Mt BSF
Mt-f/DEV/RMT/1 BSF
Mt-f/DEV/RMT/1 BSF 1 #go 1 backward file/tape (see fig.01)
Here is a list of tape location commands:
FSF advance specifies the number of file tokens. The tape is positioned in the first block of the next file.
FSFM forward Specifies the number of file tokens. The tape is positioned at the last piece of the previous file.
BSF back Specifies the number of file tokens. The tape is positioned at the last piece of the previous file.
BSFM back Specifies the number of file tokens. The tape is positioned in the first block of the next file.
ASF Tape is positioned at the beginning of the specified number of file markers. Positioning is achieved by first rewinding and then moving forward with the specified number of file tokens.
FSR advances the specified number of records.
BSR back Specifies the number of records.
FSS (SCSI Tapes) forwards the specified setmarks.
BSS (SCSI Tapes) backs up the specified setmarks.
Basic Backup Commands
Let's take a look at the backup and restore commands.
9: Backup directory (tar format)
Tar cvf/dev/rmt/0n/etc
Tar cvf/dev/st0/etc
10: Recovery directory (tar format)
Tar xvf/dev/rmt/0n-c/path/to/restore
Tar xvf/dev/st0-c/tmp
11: List or check the tape contents (tar format)
Mt-f/dev/st0 Rewind; DD If=/dev/st0 of=-
# # # tar format # # #
Tar TVF {DEVICE} {Directory-filename}
Tar tvf/dev/st0
Tar tvf/dev/st0 Desktop
Tar tvf/dev/rmt/0 foo > List.txt
12: Use Dump or ufsdump backup partition
# # Unix Backup C0T0D0S2 Partition # # #
Ufsdump 0uf/dev/rmt/0/dev/rdsk/c0t0d0s2
# # Linux Backup/home Partition # # #
Dump 0uf/dev/nst0/dev/sda5
Dump 0uf/dev/nst0/home
# # FreeBSD backup/usr partition # # #
Dump-0al-b64-f/DEV/NSA0/USR
13: Recover partition using Ufsrestore or restore
# # # Unix # #
Ufsrestore xf/dev/rmt/0
# # # Unix Interactive Recovery # # #
Ufsrestore if/dev/rmt/0
# # # Linux # #
Restore Rf/dev/nst0
# # # # 6th Interactive recovery from tape Media # # #
Restore ISF 6/dev/nst0
# # # FreeBSD Recovery ufsdump Format # # #
Restore-i-f/dev/nsa0
14: Start writing from the beginning of the tape (see Figure 02)
# # # This will overwrite all the data on the tape # # #
Mt-f/dev/st1 Rewind
# # # Backup Home # # #
Tar cvf/dev/st1/home
# # # offline and unload Tape # # #
Mt-f/dev/st0 offline
Start recovery from the beginning of the tape:
Mt-f/dev/st0 Rewind
Tar xvf/dev/st0
Mt-f/dev/st0 offline
15: Start writing from the last tar (see figure 02)
# # # This preserves previously written data # # #
Mt-f/dev/st1 EOM
# # # Backup Home # # #
Tar cvf/dev/st1/home
# # # unload # #
Mt-f/dev/st0 offline
16: Start writing from tar number 2 (see Figure 02)
# # # is written after tar number 2 (http://www.51969.com/should be 2+1) # # #
Mt-f/dev/st0 ASF 3
Tar cvf/dev/st0/usr
# # # ASF equivalent to FSF # # #
Mt-f/DEV/SF0 Rewind
Mt-f/dev/st0 FSF 2
Recover Tar from tar number 2:
Mt-f/dev/st0 ASF 3
Tar xvf/dev/st0
Mt-f/dev/st0 offline
About third-party backup tools
Linux and Unix-like systems provide a number of third-party tools that can be used to schedule backups, including tape backups, such as:
Amanda
Bacula
Rsync
Duplicity
Rsnapshot

16 Practical Linux/unix Tape Management commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.