Home  >  Article  >  System Tutorial  >  One article to handle Linux file transfer: SCP and Rsync help you manage data efficiently

One article to handle Linux file transfer: SCP and Rsync help you manage data efficiently

PHPz
PHPzforward
2024-02-11 16:10:15910browse

For people who often need to transfer files between different devices, how to transfer files efficiently is a very important issue. Two very common tools, SCP and Rsync, can help us easily transfer files in Linux systems, and each has its own unique advantages.

一篇文章搞定 Linux 文件传输:SCP 和 Rsync 帮你高效管理数据

scp command – remote copy files

scp copies the local file filename to the /data/tmp directory of the remote machine 192.168.188.188 server

scp -P 61204 -l 40000 filename username@192.168.188.188:/data/tmp/

-P port
Specifies the port to connect to on the remote host. Note that this option is written with a capital ‘P’, because -p is already reserved for preserving the times and modes of the file in rcp(1).

#-P specifies the port of the remote server ssh service. For example: the ssh port is 61204

-l limit Limits the used bandwidth, specified in Kbit/s.

-l specifies the speed limit of the copy. The unit is ct/s. For example: -l 40000 means the speed of 40000Kbit/s=40000/8KB=5MB

Note: scp does not support breakpoint resume download

rsync ssh resume upload

#rsync synchronizes the local file filename to the remote machine 192.168.188.188 server's /data/tmp directory

rsync -avzP -e 'ssh -p 61204' --

bwlimit=5000 filename username@10.20.90.101:/data/tmp/ >> scp_to_101.log

-a: Operate in archive mode, copy directories and symbolic links, equivalent to -rlptgoD.

-v: Detailed tips

-z: Compression

-P: It combines the two parameters –partial –progress

–partial
If the transfer is interrupted during the process of copying files, the default operation of rsync is to undo the previous operation, that is, to delete some of the copied files from the target machine.
If you want to resume transferring files during the next copy without re-copying all the files, you can use the -partial option to prevent rsync from deleting the copied parts when the transfer is interrupted

–progress Display progress bar

-e: The function of the parameter is to allow users to freely choose the shell program they want to use to connect to the remote server

ssh -p 61204

Specify the ssh port (not the default 22) 61204

–bwlimit: –bwlimit=5000 limits the bandwidth to 5000k Bytes/s =5MB

Above example: Use rsync to transfer the local file filename to the /data/tmp directory of 192.168.188.188. Use compressed archive transmission, speed limit 5MB, support breakpoint resume transfer. Use ssh protocol

In summary, whether we use SCP or Rsync, it can help us achieve fast, safe, and controllable file transfer in Linux systems. By correctly selecting and applying these two tools, we can manage our files and data more efficiently, thus improving our work efficiency.

The above is the detailed content of One article to handle Linux file transfer: SCP and Rsync help you manage data efficiently. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete