在google上搜到这位仁兄说“scp有断点续传功能哇”,又没说明是怎么支持的,让我无比郁闷,用了这么多年scp,就从来不知道还可以支持断点续传。

scp是远程拷贝工具,那么文件拷贝功能应该是参考cp实现的,既然cp都不支持断点续传,那么scp显然也不会支持,这个推断貌似很有道理,但未必成立,我们还是看scp的手册吧。

OpenSSH_4.1p1的scp为例,看看支持哪些选项:

The options are as follows:

-1 Forces scp to use protocol 1.

-2 Forces scp to use protocol 2.

-4 Forces scp to use IPv4 addresses only.

-6 Forces scp to use IPv6 addresses only. //-1~-6选择使用的协议 -B Selects batch mode (prevents asking for passwords or passphrases). //使用批处理模式

-C Compression enable. Passes the -C flag to ssh(1) to enable com- pression. //启用压缩

-c cipher //加密密钥 Selects the cipher to use for encrypting the data transfer. This option is directly passed to ssh(1).

-F ssh_config //指定ssh使用的配置文件 Specifies an alternative per-user configuration file for ssh. This option is directly passed to ssh(1).

-i identity_file //制定key鉴权文件 Selects the file from which the identity (private key) for RSA authentication is read. This option is directly passed to ssh(1).

-l limit //限制scp所使用的带宽 Limits the used bandwidth, specified in Kbit/s.

-o ssh_option //ssh的选项 Can be used to pass options to ssh in the format used in ssh_config(5). This is useful for specifying options for which there is no separate scp command-line flag. For full details of the options listed below, and their possible values, see ssh_config(5).

AddressFamily BatchMode BindAddress ChallengeResponseAuthentication …..

-P port //scp使用的端口 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 Preserves modification times, access times, and modes from the original file. //拷贝时,保留源文件的时间、权限

-q Disables the progress meter. //取消进度条

-r Recursively copy entire directories. //递归拷贝子目录

-S program //加密程序 Name of program to use for the encrypted connection. The program must understand ssh(1) options.

-v Verbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems. //详细模式,打印调试信息

所以,单从scp本身的功能上看,是不支持断点续传的。如果想在linux机器中同步文件,建议使用rsync,ftp等工具;如果想在高可用的环境下进行文件、数据库备份,就要考虑使用卷组同步、数据库复制等商业软件了,例如:VVR,dataguard等,不过成本都比较高,一般在关键系统中才会考虑。


Simon Lee

My blog