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]
如果需要将文件移动到远程服务器上不存在的路径,则必须:
- 这只需要一个步骤
- 这需要两个步骤
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/
如果需要将文件移动到远程服务器上不存在的路径,则必须:
- 这只需要一个步骤
- 这需要两个步骤
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)创建一个空目录结构,同步它,然后将文件同步到它们的确切位置,因为这些位置已经创建。