In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Tape devices should be used only for scheduled file archiving or for transferring data from one server to another. Generally, the tape equipment is connected to the Unix machine and controlled by mt or mtx. It is strongly recommended that you back up all your data to disk (perhaps in the cloud) and to tape devices.
In this tutorial you will learn:
Tape device name
Basic commands for managing tape drives
Basic backup and restore commands
Why back up?
A backup plan is necessary for backing up files on a regular basis, and if you prefer not to back up, the risk of losing important data is greatly increased. With backup, you have the ability to recover from disk failures. Backups can also help you resist:
Unexpected file deletion
File or file system corruption
The server is completely destroyed, including the destruction of the same disk backup due to fire or other problems
Hard drive or SSD crashes
Virus or blackmail software destroys or deletes files
You can use tape archives to back up the entire server and store it offline.
Understand tape file tags and block sizes
Each tape device can store multiple backup files. Tape backup files are created by 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) on a physical tape. There is a "tape file tag" between each tape file. This is used to indicate the end of a tape file on one 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 is stored from the physical beginning of the tape (tar # 0). Next up is tar # 1, and so on.
Tape device name on Unix
/ dev/rmt/0 or / dev/rmt/1 or / dev/rmt/ [0-127]: regular tape device name on Unix. The tape is automatically rewound.
/ dev/rmt/0n: characterized by no rewind, in other words, after the tape is used, it stays in the current state and waits for the next command.
/ dev/rmt/0b: use the tape interface, which is the behavior of BSD. 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 the density to medium.
/ dev/rmt/0u: set the density to high.
/ dev/rmt/0c: sets the 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 specific SCSI tape device name that pops up on shutdown (if possible).
Example of tape device name
/ dev/rmt/1cn indicates that unity 1 is being used, compression density, no reversal.
/ dev/rmt/0hb indicates that unity 0, high density, BSD behavior is being used.
Automatic rewind of SCSI tape device name on Linux: / dev/st0
No rewind SCSI tape device name on Linux: / dev/nst0
Automatic rewind of SCSI tape device name on FreeBSD: / dev/sa0
No rewind SCSI tape device name on FreeBSD: / dev/nsa0
How do I list installed scsi tape devices?
Enter the following command:
# Linux (see man for more information) # lsscsilsscsi-glossy commands # IBM AIX # lsdev-Cc tapelsdev-Cc adsmlscfg-vl rmt*### Solaris Unix # cfgadm-acfgadm-alluxadm probeiostat-En### HP-UX Unix # ioscan Cfioscan-funC tapeioscan-fnC tapeioscan-kfC tapemt command example
On Linux and Unix-like systems, the mt command is used to control the operation of the tape drive, such as checking status or finding files on tape or writing tape control tags. Most of the following commands need to be executed as root users. The syntax is as follows:
Mt-f / tape/device/name operation setting environment
You can set the TAPE shell variable. This is the pathname of the tape drive. The default on FreeBSD (if the variable is not set instead of null) is / dev/nsa0. It can be overridden by passing variables in the-f argument of the mt command, as explained below.
# add to your shell profile # TAPE=/dev/st1 # Linux TAPE=/dev/rmt/2 # Unix TAPE=/dev/nsa3 # FreeBSD export TAPE1: display tape / drive status mt status # Use defaultmt-f / dev/rmt/0 status # Unixmt-f / dev/st0 status # Linuxmt-f / dev/nsa0 status # FreeBSDmt-f / dev/rmt/1 status # Unix unity 1 is tape device no. 1
You can use the shell loop statement to traverse a system and locate all its tape drives as follows:
For d in 0 1 2 3 4 5do mt-f "/ dev/rmt/$ {d}" statusdone2: rewind mt rewmt rewindmt-f / dev/mt/0 rewindmt-f / dev/st0 rewind3: eject tape mt offmt offlinemt ejectmt-f / dev/mt/0 offmt-f / dev/st0 eject4: erase tape (rewind, unload tape if supported) mt erasemt-f / dev/st0 erase # Linuxmt-f / dev/rmt/0 erase # Unix5: tighten the tape cartridge
If there is an error while reading the tape, you retighten the tape, clean the tape drive, and try again like this:
Mt retensionmt-f / dev/rmt/1 retension # Unixmt-f / dev/st0 retension # Linux6: write the EOF tag mt eofmt weofmt-f / dev/st0 eof7 at the current location of the tape: move the tape forward by the specified number of file tags, that is, skip the specified EOF tag
The tape is positioned in the first block of the next file, that is, the tape is positioned in the first block of 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 the tape by the specified number of file tags, that is, rewind the tape to specify an EOF tag
The tape is positioned in the first block of the next file, that is, 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 positioning commands:
The number of file tags specified by the fsf forward. The tape is positioned in the first block of the next file. The number of file tags specified by the fsfm forward. The tape is positioned in the last piece of the previous file. Bsf reverses the specified number of file tags. The tape is positioned in the last piece of the previous file. Bsfm reverses the specified number of file tags. The tape is positioned in the first block of the next file. The asf tape is positioned at the beginning of the specified number of file tags. Positioning is achieved by rewinding and then advancing the specified number of file tags. Fsr advances the specified number of records. Bsr reverses the specified number of records. Fss (SCSI tapes) advances the specified setmarks. Bss (SCSI tapes) reverses the specified setmarks. Basic backup command
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 / etc10: restore directory (tar format) tar xvf / dev/rmt/0n-C / path/to/restoretar xvf / dev/st0-C / tmp11: list or check 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.txt12: 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/sda5dump 0uf / dev/ Nst0 / home### FreeBSD backup / usr partition # dump-0aL-b64-f / dev/nsa0 / usr13: using ufsrestore or restore to restore partition # Unix # ufsrestore xf / dev/rmt/0### Unix interactive recovery # ufsrestore if / dev/rmt/0### Linux # # restore rf / dev/nst0### interactive recovery from the sixth backup on tape media # restore isf 6 / dev / nst0### FreeBSD recovery ufsdump format # restore-I-f / dev/nsa014: write from the beginning of the tape (see figure 02) # this will overwrite all data on the tape # mt-f / dev/st1 rewind### backup home### tar cvf / dev/st1 / home### offline and unmount the tape # # mt-f / dev/st0 offline
Restore from the beginning of the tape:
Mt-f / dev/st0 rewindtar xvf / dev/st0mt-f / dev/st0 offline15: write after the last tar (see figure 02) # this retains the previously written data # mt-f / dev/st1 eom### backup home### tar cvf / dev/st1 / home### uninstall # mt-f / dev/st0 offline16: write after tar number 2 (see figure 02) # in Write after tar number 2 (should be 2x1) # mt-f / dev/st0 asf 3tar cvf / dev/st0 / usr### asf is equivalent to fsf # mt-f / dev/sf0 rewindmt-f / dev/st0 fsf 2
Restore tar from tar number 2:
Mt-f / dev/st0 asf 3tar xvf / dev/st0mt-f / dev/st0 offline about third-party backup tools
Both Linux and Unix-like systems provide many third-party things that can be used to organize backups, including tape backups, such as:
Amanda
Bacula
Rsync
Duplicity
Rsnapshot
Original link: http://www.magedu.com/71669.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.