2017-07-15 73 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/ 
相關問題