Use of tape drives in linux

Source: Internet
Author: User
Tags gz file rewind

In Linux, there are multiple ways to use the tape drive. The tar command is the most frequently used method. tar is mainly used to directly write data to the tape drive in a single-host environment. The device name of the tape drive in Linux is/dev/stX. If it is the first tape drive, that is,/dev/st0, the basic operation is as follows:
(1) rewind to roll the tape to the starting position
Mt-f/dev/st0 rewind
(2) erase the content on the tape
Mt-f/dev/st0 erase
The newly purchased tape can be used after it is opened, without the need to erase the write operation. when the data is full, the tape can overwrite the original data and continue writing the data. Therefore, no write operation is required, it is recommended that you do not perform the write operation because the tape is damaged.
(3) outbound tape, that is, to bring the tape to the initial position and then pop up from the tape drive
Mt-f/dev/st0 offline
(4) use tar to list directories or files on the tape
Tar tvf/dev/st0 [files or directories to be viewed]
If no file or directory is followed, it is to view all data on the tape. If no data is available on the tape, an error is returned when this operation is performed, but the usage of the tape is not affected.
(5) Back up data to tape through tar
Tar cvf/dev/st0 [name of the file or directory to be written]
There are two ways to back up data to a tape: Package, compress, and write data to the tape directly without packaging. Here we recommend that you write data directly to the tape without packaging. This improves the security of data storage. Why do we recommend that you do not package backups? Because tapes write data sequentially, that is, linear storage. If you package all the data into an independent file, when the tape fails anywhere, this compression file may fail to be decompressed and cannot be used. If the backup data is not packaged and stored, there will be a lot of files on the tape, even if the tape is faulty somewhere, the remaining files are still available, which greatly improves the security of data backup.
For example, to write the/data/ixdba1.tar.gz compressed file to the tape and overwrite the original content, you can perform the following operations:
[Root @ webserver/data] # tar cvf/dev/st0/data/ixdba1.tar.gz
When "tar cvf" is used to write data to a tape, the original data of the tape is overwritten each time, that is, the data is written from the beginning of the tape. The transmission speed of the tape drive is relatively slow. For non-large backup files, the backup can be completed in a short time, which is very suitable for system-level file backup.
(6) continue writing data to the tape through tar
Tar rvf/dev/st0 [file name to be written]
Because tapes are linearly stored and data is written in sequence, to avoid overwriting existing data when writing new data, you can use the "tar rvf" parameter combination to write data to the tape in sequence.
For example, back/data/ixdba2.tar.gz and/data/ixdba3.tar.gz to the tape drive in sequence:
[Root @ webserver/data] # tar rvf/dev/st0/data/ixdba2.tar.gz
[Root @ webserver/data] # tar rvf/dev/st0/data/ixdba3.tar.gz
(7) use tar to restore data from tape to disk
Tar xvf/dev/st0 [name of the file or directory to be restored]
For example, first check all the data on the tape:
[Root @ webserver ~] # Tar tvf/dev/st0
-Rw-r -- root/root 320 10:19:02 ixdba1.tar.gz
-Rw-r -- root/root 320 10:25:10 ixdba2.tar.gz
-Rw-r -- root/root 320 10:45:18 ixdba3.tar.gz
To restore the ixdba2.tar.gz file on the drive to the disk, run the following command:
[Root @ webserver ~] # Tar xvf/dev/st0 ixdba2.tar.gz
Ixdba2.tar.gz
In this way, the data is restored from the tape to the current path.
This article is from the "netsword.blogchina.com" blog

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.