充实Simon的答案,rsync
是完成这项工作的完美工具:
Rsync is a fast and extraordinarily versatile file copying
tool. It can copy locally, to/from another host over any
remote shell, or to/from a remote rsync daemon. It offers a
large number of options that control every aspect of its
behavior and permit very flexible specification of the set of
files to be copied. It is famous for its delta-transfer algo‐
rithm, which reduces the amount of data sent over the network
by sending only the differences between the source files and
the existing files in the destination. Rsync is widely used
for backups and mirroring and as an improved copy command for
everyday use.
假设您具有对远程计算机的ssh访问权限,则需要执行以下操作:
rsync -hrtplu path/to/local/foo user@remote.server.com:/path/to/remote/bar
这会将目录复制path/to/local/foo
到/path/to/remote/bar
远程服务器上。bar/foo
将创建一个名为的新子目录。如果只想复制目录的内容,而不在目标机上创建该目录的目录,请添加斜杠:
rsync -hrtplu path/to/local/foo/ user@remote.server.com:/path/to/remote/bar
这会将内容复制foo/
到远程目录bar/
。
一些相关选项:
-h, output numbers in a human-readable format
-r recurse into directories
-t, --times preserve modification times
-p, --perms preserve permissions
-l, --links copy symlinks as symlinks
-u, --update skip files that are newer on the receiver
--delete delete extraneous files from dest dirs
-z, --compress compress file data during the transfer
-C, --cvs-exclude auto-ignore files in the same way CVS does
--progress show progress during transfer
--stats give some file-transfer stats
rsync
吗?也许只有一小部分文件?应该是理想的工具。