UNIX commands have three valid data streams: standard input, standard output, and standard error.
A pipeline is a technology that transfers information one way from one program process to another. Unlike other forms of inter-process communication, such as IPC, message passing, and SOCKET, pipelines are unidirectional. Generally, an MPS queue transmits the output of a process to another process as the input. The system temporarily retains MPs queue information before receiving information from processes.
In UNIX shell, a pipe is represented by a vertical bar (|) in the command line. The standard output of the command on the left of the pipeline serves as the standard input of the command on the right of the pipeline.
UNIX Input and Output redirection transfers standard input and output of commands from the keyboard and terminal to other device files.
We can use the pipeline and input/output redirection functions to skillfully implement some functions in UNIX systems. The following three examples are provided (assuming that the user has the corresponding permissions ).
I. The host tom does not have a tape drive, while the host jerry has a tape drive.
Our task is to back up tom's data to the tape through jerry.
Suppose we want to use the tar command to back up the/dir directory to the tape.
First, modify the file/etc/hosts on tom and add the IP address of jerry:
192.0.0.2 jerry
Ping jerry to check whether the network is smooth.
Modify tom's. rhosts and add it to the downstream:
Jerry
Make jerry a trusted host of tom.
Now, on jerry, rlogin tom, under normal circumstances, you do not need a password and should be able to log on to the tom machine.
On jerry, run:
Rsh tom "" tar cvf-/dir "">/dev/rmt0h
Here, tar cvf-/dir copies/dir to the standard output, and then redirects it to the tape drive on the host jerry to complete the backup.
II. How to Implement simultaneous backup of tape drives on multiple hosts to speed up backup.
With the acceleration of the informatization process, many enterprises have developed from manual operations to the use of information technology to improve productivity. enterprises have also accumulated a large amount of data, and many databases require operation.
The backup process of the database reduces the server performance even if it is not stopped. The advantage of minimizing the backup time window is obvious.
However, only one tape drive is configured on a UNIX host. Assuming we have another UNIX host with a tape drive available, we can use two tape drives to work at the same time to speed up the backup time.