How to transfer large amounts of small files between two VPS

888u

Last update at :2024-05-04,Edit by888u


The easiest way to transfer a large number of fragmented files between two VPS is to compress them and wget them. However, if the total files are too large, our hard disk may not be enough to compress them. Of course, if you are as smart as you, you must have thought of it, so I will compress part of it, and after wget passes, compress the other part, and do it a few more times, isn't that enough?

When you find that this path doesn't work, you will still use rsync to synchronize. But it always feels uncomfortable to install such a strange tool in a production environment.

In fact, we can also achieve this purpose through tar.

Among the uses of tar, there is one of the most special ways, which is to package and decompress the files to be processed through standard input/output data flow redirection (standard input/standard output) and pipeline commands (pipe). Go to the target directory. Of course, you can also extract it to the directory of the VPS we specified.

Assume that we now need to transfer the /etc directory of this machine to another vps. The IP address of that VPS is: 104.129.14.39, and the SSH port is 22. Let's also assume that it is transferred to the /tmp directory, then The command is as follows:

tar -cv -f - /etc | ssh -p 22 root@104.129.14.39 tar -xv -f - -C /tmp


Then enter the password of your VPS and wait slowly. Of course, because the transmission takes a lot of time, we may need to turn on screen. For related commands, you can search on this blog.


In addition, you can also use the scp command, but in terms of usability, it seems that scp is slower. The command is as follows:

scp -P 22 -r /etc root@104.129.14.39:/tmp


Next time I want to transfer files directly between two vps, wouldn’t it be much more convenient?

Recommended site searches: Wanwang domain name space, website virtual host, Hong Kong host high defense, ICP registration website, Ministry of Industry and Information Technology website registration inquiry, overseas virtual host, private server rental, independent IP space, check IP detailed address , Hong Kong free virtual host

How to transfer large amounts of small files between two VPS

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码