使用 rsync 从 Windows 传输到 Linux
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4182286/
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
Transferring from Windows to Linux with rsync
提问by andrewk
noob here,
这里的菜鸟,
I'm trying to transfer a file using rsync from windows to linux. I have this code, but I'm getting an error
我正在尝试使用 rsync 将文件从 windows 传输到 linux。我有此代码,但出现错误
rsync -avz -e ssh C:\users\file.txt [email protected]:/var/dir
I get this error The source and destination cannot be both remote
我收到此错误源和目标不能都是远程的
And if I try
如果我尝试
rsync -avz -e ssh /c/users/file.txt [email protected]:/var/dir
I get, No such file or directory
我明白了,没有这样的文件或目录
So, I think the problem is with the path of the file on the windows.. I've heard about cygwin but haven't really tried it
所以,我认为问题出在 Windows 上文件的路径上。我听说过 cygwin 但还没有真正尝试过
What can I do to get the path to work?
我该怎么做才能找到工作路径?
采纳答案by paxdiablo
If you're using CygWin to rsync from the Windows box, the local file you want is almost certainly:
如果您使用 CygWin 从 Windows 框中进行 rsync,您想要的本地文件几乎肯定是:
/cygdrive/c/users/file.txt
rather then:
而不是:
/c/users/file.txt
回答by Mareg
Writing the right rsyncd.conf
is a little bit complicated.
正确书写rsyncd.conf
有点复杂。
I get the error message
我收到错误消息
@ERROR: chdir failed rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=2.6.8]
@ERROR:chdir failed rsync 错误:在 main.c(1296) [receiver=2.6.8] 处启动客户端-服务器协议(代码 5)时出错
and
和
2012/06/10 14:59:43 [9252] rsync: chdir /cygdrive/d failed : No such file or directory (2)
2012/06/10 14:59:43 [9252] rsync: chdir /cygdrive/d 失败:没有这样的文件或目录 (2)
Because I miss the "use chroot = false"
directive in my rsyncd.conf
因为我错过了我的"use chroot = false"
指令rsyncd.conf
Here is an example of rsyncd.conf
:
下面是一个例子rsyncd.conf
:
log file = c:/rsync.log
auth users = backup
secrets file = /cygdrive/c/Program Files/RSync/rsyncd.secrets
[backup]
comment = Backup this host
path = /cygdrive/d
use chroot = false
strict modes = false
read only = false
transfer logging = yes
hosts allow = 192.168.2.252
Be sure the rsync.log
file is created/changed after restart service, if it's not done, you have some error in your rsyncd.conf
file and the rsync does'nt use them but no error or info is showed at all!
确保rsync.log
在重新启动服务后创建/更改文件,如果未完成,则您的rsyncd.conf
文件中有一些错误并且 rsync 不使用它们,但根本没有显示任何错误或信息!
And so, the format of rsyncd.secrets
file, is:
因此,rsyncd.secrets
文件的格式是:
backup:<password>