2017-07-15 648 views
0

我想在远程桌面上使用远程桌面来创建目录树,以及在远程桌面上指定。我使用的是下面的命令,但它不工作当目录在远程服务器中不存在时。rsync命令给出错误没有这样的文件或目录(2)

rsync -avzhe ssh --progress /root/BP/temp/temp.txt [email protected]:/root/BP/temp2 

哪里/root/BP/temp/temp.txt可在本地,但/root/BP/temp2这条路是不是在远程服务器peresent。

我得到以下错误:

rsync: change_dir#3 "/root/BP" failed: No such file or directory (2) 
rsync error: errors selecting input/output files, dirs (code 3) at main.c(625) [Receiver=3.0.9] 
rsync: connection unexpectedly closed (9 bytes received so far) [sender] 
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9] 

回答

0

你需要提前在服务器上创建一个目录来执行rsync这种方式。

0

如果您需要将文件移动到一个不存在的路径在远程服务器上,你必须:

  1. 模式的路径和文件结构本地及同步一个共同的“祖先”。
    • 这是只需要1步
  2. 本地创建缺少的目录,并同步他们先再同步的文件。
    • 这需要两个步骤

要使用OP的具体例子:

rsync -avzhe ssh --progress /root/BP/temp/temp.txt [email protected]:/root/BP/temp2 

你反而会做的事:

# assuming that /root already exists on the remote server 
mkdir -p /root/BP/temp/or_wherever/BP/temp2 
mv /root/BP/temp/temp.txt /root/BP/temp/or_wherever/BP/temp2 
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP [email protected]:/root/ 

但是,如果由于某种原因你不能移动有问题的文件,你必须使用th e第二种选择:

# assuming that /root already exists on the remote server 
mkdir -p /root/BP/temp/or_wherever/BP/temp2 
# Notice there is no `/` after the  `or_wherever/BP` in the next command 
rsync -avzhe ssh --progress /root/BP/temp/or_wherever/BP [email protected]:/root/ 
rsync -avzhe ssh --progress /root/BP/temp/temp.txt [email protected]:/root/BP/temp2/ 
相关问题