远程 Linux 服务器到远程 linux 服务器目录复制。如何?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/69411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:25:04  来源:igfitidea点击:

Remote Linux server to remote linux server dir copy. How?

linuxdata-transfer

提问by

What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both.

将目录(带有子目录和文件)从一台远程 Linux 服务器复制到另一台远程 Linux 服务器的最佳方法是什么?我已经使用 SSH 客户端(如 Putty)连接到两者。我对两者都有 root 访问权限。

回答by Ana Betts

rsync -avlzp /path/to/folder [email protected]:/path/to/remote/folder

rsync -avlzp /path/to/folder [email protected]:/path/to/remote/folder

回答by John Douthat

Check out scpor rsync, man scpman rsync

查看scprsyncman scpman rsync

scp file1 file2 dir3 user@remotehost:path

回答by Ady Romantika

Use rsync so that you can continue if the connection gets broken. And if something changes you can copy them much faster too!

使用 rsync 以便在连接中断时您可以继续。如果有什么变化,你也可以更快地复制它们!

Rsync works with SSH so your copy operation is secure.

Rsync 与 SSH 配合使用,因此您的复制操作是安全的。

回答by Cody Brocious

scp -r <directory> <username>@<targethost>:<targetdir>

回答by zigdon

Well, quick answer would to take a look at the 'scp' manpage, or perhaps rsync - depending exactly on what you need to copy. If you had to, you could even do tar-over-ssh:

好吧,快速回答是查看“scp”联机帮助页,或者可能是 rsync - 完全取决于您需要复制的内容。如果必须,您甚至可以执行 tar-over-ssh:

tar cvf - | ssh server tar xf -

回答by Flame

Log in to one machine

登录到一台机器

$ scp -r /path/to/top/directory user@server:/path/to/copy

$ scp -r /path/to/top/directory user@server:/path/to/copy

回答by Allan Wind

As non-root user ideally:

理想情况下,作为非 root 用户:

scp -r src $host:$path

scp -r src $host:$path

If you already some of the content on $host consider using rsync with ssh as a tunnel.

如果您已经有 $host 上的一些内容,请考虑使用 rsync 和 ssh 作为隧道。

/Allan

/艾伦

回答by Ycros

There are two ways I usually do this, both use ssh:

我通常有两种方法,都使用 ssh:

scp -r sourcedir/ [email protected]:/dest/dir/

or, the more robust and faster (in terms of transfer speed) method:

或者,更健壮和更快(在传输速度方面)的方法:

rsync -auv -e ssh --progress sourcedir/ [email protected]:/dest/dir/

Read the man pages for each command if you want more details about how they work.

如果您想了解有关它们如何工作的更多详细信息,请阅读每个命令的手册页。

回答by user11104

Try unison if the task is recurring. http://www.cis.upenn.edu/~bcpierce/unison/

如果任务重复出现,请尝试统一。 http://www.cis.upenn.edu/~bcpierce/unison/

回答by Ram Prasad

I think you can try with:

我认为你可以尝试:

rsync -azvu -e ssh user@host1:/directory/ user@host2:/directory2/

(and I assume you are on host0 and you want to copy from host1 to host2 directly)

(我假设您在 host0 上,并且想直接从 host1 复制到 host2)

If the above does not work, you could try:

如果上述方法不起作用,您可以尝试:

ssh user@host1 "/usr/bin/rsync -azvu -e ssh /directory/ user@host2:/directory2/"

in the this, it would work, if you already have setup passwordless SSH login from host1 to host2

在此,如果您已经设置了从主机 1 到主机 2 的无密码 SSH 登录,它会起作用