抱歉,这里的其他答案太复杂了:-7。一个对我有用的更简单的答案:(使用 rsync over -e ssh)
# optionally move rsync temp file, then resume using rsync
dst$ mv .<filename>.6FuChr <filename>
src$ rsync -avhzP --bwlimit=1000 -e ssh <fromfiles> <user@somewhere>:<destdir>/
从中断的 scp 恢复时也有效。
Rsync 创建一个临时文件...临时文件快速增长到部分传输文件的大小。转让简历。
Scp 写入实际的最终目标文件。如果传输中断,这是一个截断的文件。
参数解释:
-avhz .. h=humanoid, v=verbose, a=archive, z=compression .. archive 指示它维护 time_t 值,因此即使时钟已用完,rsync 也知道每个文件的真实日期
-P 是 --partial --progress 的缩写。--partial 告诉 rsync 保留部分传输的文件(并且在恢复 rsync 将始终在安全校验和后使用部分传输的文件)
从手册页:
http ://ss64.com/bash/rsync_options.html
--partial
By default, rsync will delete any partially transferred file if the transfer
is interrupted. In some circumstances it is more desirable to keep partially
transferred files. Using the --partial option tells rsync to keep the partial
file which should make a subsequent transfer of the rest of the file much faster.
--progress
This option tells rsync to print information showing the progress of the transfer.
This gives a bored user something to watch.
This option is normally combined with -v. Using this option without the -v option
will produce weird results on your display.
-P
The -P option is equivalent to --partial --progress.
I found myself typing that combination quite often so I created an option to make
it easier.
注意:对于多次中断的连接:
如果您需要在 rsync 后恢复(连接中断后),那么最好重命名目标上的临时文件。scp 在目标上创建一个与最终文件同名的文件。如果 scp 被中断,则此文件是该文件的截断版本。rsync (-avzhP) 将从该文件恢复,但开始写入临时文件名,如 ..Yhg7al。
使用 scp 启动时的过程:
scp; *interrupt*; rsync; [REPEAT_as_needed: *interrupt*; mv .destfile.tmpzhX destfile; rsync;].
使用 rsync 启动时的过程:
rsync; [REPEAT_as_needed: *interrupt*; mv .destfile.tmpzhX destfile; rsync;].