Direct Backup Operation Using Tape Drive under Linux

Tape Operations After
loading a tape, you can perform the following operations:
Rewind, rewind the tape to the starting position
mt -f /dev/st0 rewind
Erase, erase the contents of the tape
mt -f /dev/st0 erase
Note: Erasing is very slow and damages the tape. It is best not to execute it. When the data is full, you can continue to write data and overwrite the original. If there is data, there is no need to perform the erasing action. New tapes are ready to use immediately after unpacking, and no erasing is required.
unload, roll the tape to its original position and eject it from the tape drive
mt –f /dev/st0 offline

Data operation The
basic operations are as follows:
1. List directory operation tar tvf /dev/st0
If there is no file on the tape, the list directory will report an error. This error is not relevant and does not affect the use of the tape.
2. Write data operation tar cvf /dev/st0 <file name to be written>
There are two ways to write data: directly write to the file without packaging and write to the file after packaging and compression. Both have advantages and disadvantages. The method of directly writing files without packaging seems to be inefficient and complicated to operate, but it can improve the survival rate of data. A tape is a linear storage device where all data is written next to each other sequentially. When a certain point of the tape is damaged, the tapes in other positions can continue to be read, and the files in it can also be read. If the method of packing and compressing and writing is adopted, only one file is stored on the tape. When any part of the tape fails and cannot be read, the compressed file will lack some details. Even a bit error will cause the compressed file to report a CRC error and cannot be decompressed. Therefore, if it is to store a large amount of data, it is recommended to write directly. If you are accessing small files, it is better to pack and write with a time stamp to the file name.
For example, to write /root/test1.tar.gz to the tape and overwrite the contents of the tape:
tar cvf /dev/st0 test1.tar.gz
The transfer speed of the tape drive is relatively slow, for the backup of not very large files, wait a moment In a few seconds, the write is complete. Using the parameter cvf will overwrite existing files on this tape.
3. Continue to write data tar rvf /dev/st0 <file name to be written>
Tape storage is linear, and all data is written sequentially. In order not to overwrite the previous content, when writing, use the rvf parameter to write the content.
tar rvf /dev/st0 test2.tar.gz
Execute rvf again to continue writing other files:
tar rvf /dev/st0 test3.tar.gz
4. Read data tar xvf /dev/st0 <file name to read>
Before reading the data, first check the contents of the tape (tar tvf /dev/st0) to obtain the file name to be recovered.
After reading the data.
The file read from the tape can then be found in the current path, and the recovery operation is now complete.
Through the tar command described above, using the tvf/cvf/rvf/xvf parameters, you can read and write to the tape. Use the pre-written copy data script, cooperate with the tape drive operation command, and place it in /etc/crontab to realize automatic backup.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326993514&siteId=291194637