Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix rsync命令没有给出这样的文件或目录错误(2)_Unix_Rsync - Fatal编程技术网

Unix rsync命令没有给出这样的文件或目录错误(2)

Unix rsync命令没有给出这样的文件或目录错误(2),unix,rsync,Unix,Rsync,我正在尝试在远程桌面中使用传输文件,该文件将按照指定在远程桌面中创建目录树。我正在使用以下命令,但当远程服务器中不存在目录时,该命令不起作用 rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/root/BP/temp2 其中/root/BP/temp/temp.txt在本地可用,但/root/BP/temp2在远程服务器中不发送此路径 rsync -avzhe ssh --progress /root/BP/temp/

我正在尝试在远程桌面中使用传输文件,该文件将按照指定在远程桌面中创建目录树。我正在使用以下命令,但当远程服务器中不存在目录时,该命令不起作用

rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/root/BP/temp2
其中
/root/BP/temp/temp.txt
在本地可用,但
/root/BP/temp2
在远程服务器中不发送此路径

rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/root/BP/temp2
我得到以下错误:

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]

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

  • 本地建模路径和文件结构,并同步一个公共“祖先”。
    • 这只需要一个步骤
  • 在本地创建丢失的目录,并首先同步它们,然后同步文件。
    • 这需要两个步骤
  • 要使用OP的具体示例,请执行以下操作:

    rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/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 root@host2:/root/
    
    但如果由于某种原因无法移动相关文件,则必须使用第二个选项:

    # 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 root@host2:/root/
    rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/root/BP/temp2/
    

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

  • 本地建模路径和文件结构,并同步一个公共“祖先”。
    • 这只需要一个步骤
  • 在本地创建丢失的目录,并首先同步它们,然后同步文件。
    • 这需要两个步骤
  • 要使用OP的具体示例,请执行以下操作:

    rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/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 root@host2:/root/
    
    但如果由于某种原因无法移动相关文件,则必须使用第二个选项:

    # 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 root@host2:/root/
    rsync -avzhe ssh --progress /root/BP/temp/temp.txt root@host2:/root/BP/temp2/
    

    这似乎会复制整个文件夹
    BP
    。如果其中还有其他文件,但您只想移动
    temp.txt
    及其目录祖先,该怎么办?@P1h3r1e3d13我真的看不到第三个选项。是,
    rsync
    将同步“其他文件”。因此,您可以:(上面的选项1)在本地创建一个愿意同步的目录和文件结构。或者,(上面的选项2)创建一个空目录结构,同步它,然后将文件同步到它们的确切位置,因为位置已经创建。这似乎会复制整个文件夹
    BP
    。如果其中还有其他文件,但您只想移动
    temp.txt
    及其目录祖先,该怎么办?@P1h3r1e3d13我真的看不到第三个选项。是,
    rsync
    将同步“其他文件”。因此,您可以:(上面的选项1)在本地创建一个愿意同步的目录和文件结构。或者,(上面的选项2)创建一个空目录结构,同步它,然后将文件同步到它们的确切位置,因为这些位置已经创建。