Restore partially transferred files using rsync and SSH

rsync is a powerful file synchronization tool that enables secure file transfer through the SSH protocol. In some cases, the transfer process may be interrupted or terminated unexpectedly, resulting in only some files being transferred successfully. In this case, rsync provides a way to resume partial transfers, enabling you to transfer only missing files or parts of files without retransmitting the entire file.

Here are the steps to restore partially transferred files using rsync and SSH:

  1. Make sure your system has rsync and SSH installed. You can check if they are installed by running the following command in the terminal:

    rsync --version
    ssh -V
    ```
    
    如果这些命令没有找到或报错,你需要安装它们。
    
    
  2. Use the following command to restore partially transferred files:

    rsync --partial --progress --rsh=ssh [源文件] [目标文件]
    ```
    
    - `--partial`选项告诉rsync保留部分传输的文件,并继续传输剩余的部分。
    - `--progress`选项显示传输进度。
    - `--rsh=ssh`选项指定使用SSH协议进行传输。
    
    请将`[源文件]`替换为传输中断时的源文件路径,将`[目标文件]`替换为传输中断时的目标文件路径。
    
    
  3. After running the command, rsync will begin to resume transferring the interrupted files. It will calculate the missing file blocks and transfer only these missing blocks to minimize the amount of data transferred.

    sending incremental file list
    [文件名]: 100% [已传输的块数] [传输速度] [剩余时间] [已传输的文件大小]
    ```
    
    传输进度将显示在终端上,你可以看到已传输的块数、传输速度、剩余时间和已传输的文件大小。
    
    
  4. Once the transfer is complete, you will restore the partially transferred files and merge them with the destination files.

Now you know how to restore partially transferred files using rsync and SSH. This method can help you avoid retransmitting the entire file when the transfer is interrupted, saving time and bandwidth. Remember to replace the source file and target file paths in the command according to your actual situation.

Guess you like

Origin blog.csdn.net/ai52learn/article/details/133561974