15 Useful Linux/unix Tape management instructions

Source: Internet
Author: User
Tags rewind

Tape devices should be used only for timed file archives or for transferring data from one server to another. The general tape device is connected to a Unix machine and manipulated with Mt or MTX. It is strongly recommended that you back up all of your data to disk (perhaps in the cloud) and tape devices.

In this tutorial you will learn:

    1. Tape Device Name

    2. Basic commands for managing tape drives

    3. 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:

    1. Accidental file deletion

    2. file or file system corruption

    3. The server is completely destroyed, including a backup of the same disk caused by a fire or other problem

    4. Hard disk or SSD crashes

    5. 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).


650) this.width=650; "title=" "src=" http://www.linuxprobe.com/wp-content/uploads/2016/05/tape-management_02.jpg " alt= "Tape management_02" width= "580" height= "" style= "border:0px;vertical-align:middle;margin:0px auto;height: auto; "/>


How the data on the tape is stored


650) this.width=650; "title=" "src=" http://www.linuxprobe.com/wp-content/uploads/2016/05/tape-management_03.jpg " alt= "Tape management_03" width= "598" height= "229" style= "border:0px;vertical-align:middle;margin:0px auto;height: auto; "/>


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
    1. /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.

    2. /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.

    3. /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.

    4. /DEV/RMT/0L: Set the density to low.

    5. /dev/rmt/0m: Set density to medium.

    6. /DEV/RMT/0U: Set the density to high.

    7. /DEV/RMT/0C: Set density to compression.

    8. /DEV/ST[0-9]: Linux specific SCSI tape device name.

    9. /DEV/SA[0-9]: FreeBSD specific SCSI tape device name.

    10. /dev/esa0:freebsd a specific SCSI tape device name, which pops up when it is turned off (if available).

Tape Device Name Example
    1. /DEV/RMT/1CN indicates that Unity 1 is being used, compression density, no rewind.

    2. /DEV/RMT/0HB indicates that unity 0, high density, BSD behavior is being used.

    3. Auto-Rewind SCSI tape device name on Linux:/dev/st0

    4. Non-inverted SCSI tape device name on Linux:/dev/nst0

    5. Auto-Rewind SCSI tape device on FreeBSD name:/dev/sa0

    6. 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) # # #lsscsilsscsi-g### IBM AIX # # #lsdev-cc tapelsdev-cc adsmlscfg-vl rmt*### Solaris Unix # # #cfgad M–ACFGADM-ALLUXADM probeiostat-en### HP-UX Unix # # #ioscan cfioscan-func TAPEIOSCAN-FNC TAPEIOSCAN-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 defaultmt-f/dev/rmt/0 status # # # unixmt-f/dev/st0 Status # # Linuxmt-f/dev/nsa0 Status # # # FreeB Sdmt-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 5do mt-f "/dev/rmt/${d}" Statusdone
2: Rewind
Mt REWMT rewindmt-f/dev/mt/0 rewindmt-f/dev/st0 Rewind
3: Eject Tape
Mt offmt offlinemt ejectmt-f/dev/mt/0 offmt-f/dev/st0 Eject
4: Erase tape (rewind, unload tape in case of support)
Mt Erasemt-f/dev/st0 Erase #Linuxmt-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 Retensionmt-f/DEV/RMT/1 retension #Unixmt-F/dev/st0 retension #Linux
6: Write the EOF tag at the current position of the tape
Mt Eofmt Weofmt-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 Fsfmt-f/dev/rmt/0 fsfmt-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 bsfmt-f/DEV/RMT/1 bsfmt-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/etctar cvf/dev/st0/etc
10: Recovery directory (tar format)
Tar xvf/dev/rmt/0n-c/path/to/restoretar 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/st0tar tvf/dev/st0 Desktoptar 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### from the tape media 6th Backup Interactive Recovery # # #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 data on 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 Rewindtar xvf/dev/st0mt-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### Uninstall # # #mt-F/dev/st0 offline
16: Start writing from tar number 2 (see Figure 02)
# # # is written after tar number 2 (should be 2+1) # # #mt-F/dev/st0 asf 3tar cvf/dev/st0/usr### asf equivalent to FSF # # #mt-F/dev/sf0 rewindmt-f /dev/st0 FSF 2

Recover Tar from tar number 2:

Mt-f/dev/st0 asf 3tar xvf/dev/st0mt-f/dev/st0 offline
About third-party backup tools

Linux and Unix-like systems provide a number of third-party things that can be used to organize backups, including tape backups, such as:

    1. Amanda

    2. Bacula

    3. Rsync

    4. Duplicity

    5. Rsnapshot

Original link: http://www.magedu.com/71669.html


This article is from the "Marco Linux Training" blog, so be sure to keep this source http://mageedu.blog.51cto.com/4265610/1926414

15 Useful Linux/unix Tape management instructions

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.