【问题标题】:rsync succeeds of fails depending on the destination directoryrsync 成功或失败取决于目标目录
【发布时间】:2021-10-23 19:15:17
【问题描述】:

我正在使用空的/home/pantelis 文件夹(即目标目录)进行下面的两个实验

此命令成功:

rsync -zalP --progress --exclude=.git --exclude=.vscode /Users/pantelis/Workspace/my-work/terragrunt/modules/ my-server:/home/pantelis/my-work/

即在my-server 上,my-work 目录被创建并且具有/Users/pantelis/Workspace/my-work/terragrunt/modules/ 的内容

在远程机器上,我现在删除了/home/pantelis/my-work,所以/home/pantelis 再次为空。

我尝试如下运行rsync 命令,但现在失败了

▶ rsync -zalP --progress --exclude=.git --exclude=.vscode /Users/pantelis/Workspace/my-work/terragrunt/modules/ my-server:/home/pantelis/my-work/terragrunt/modules/
building file list ...
1114 files to consider
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /System/Volumes/Data/SWE/macOS/BuildRoots/d7e177bcf5/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/io.c(453) [sender=2.6.9]

我正在尝试这个,显然我希望远程文件结构与本地文件结构匹配。

为什么第二次尝试失败了?

是因为(某些内在原因)rsync 不能创建除叶子之外的任何其他目录吗? (my-work)?在那种情况下,我尝试了--relative 建议的here 选项,但没有任何成功。

【问题讨论】:

    标签: ssh rsync scp


    【解决方案1】:

    将此添加到您的命令中以在我的服务器上创建缺少的目录层次结构:

    --rsync-path="mkdir -p /home/pantelis/my-work/terragrunt/modules/ && rsync"
    

    【讨论】:

      猜你喜欢
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 2018-06-30
      • 2017-09-13
      • 2017-10-19
      • 1970-01-01
      相关资源
      最近更新 更多