scp命令本身不支持中断续传,scp(Secure Copy)使用的是 SSH 协议进行文件传输,它不内置断点续传功能。如果传输过程中中断(网络断开、连接超时、手动终止等),您需要重新开始整个文件的传输。
rsync是功能更强大的文件同步工具,天然支持断点续传,并且可以增量传输(只传输变化的部分)。
-
先使用
rsync检查已传输的部分:# 使用 --dry-run 查看需要传输的内容 rsync -avP --dry-run source_file user@remote_host:/path/to/destination/ -
在
scp中断后立即切换到rsync:# scp 中断后,改用 rsync 继续 rsync -avP --append source_file user@remote_host:/path/to/destination/ # --append 选项会从文件末尾继续追加数据 -
对于大文件传输,直接使用
rsync:最可靠的传输方式
rsync -avP --append-verify source_file user@remote_host:/path/to/destination/
参数说明:
-a:归档模式,保持文件属性
-v:显示详细信息
-P:等价于 --partial --progress,保留部分传输的文件并显示进度
如果传输中断,重新运行相同的命令即可继续传输