I am conducting both experiments below with empty /home/pantelis
folder (which is the destination directory)
This command succeeds:
rsync -zalP --progress --exclude=.git --exclude=.vscode /Users/pantelis/Workspace/my-work/terragrunt/modules/ my-server:/home/pantelis/my-work/
i.e. on my-server
, my-work
directory is created and has the contents of /Users/pantelis/Workspace/my-work/terragrunt/modules/
On the remote machine, I now delete /home/pantelis/my-work
so /home/pantelis
is once again empty.
I try to run the rsync
command as follows which now fails
▶ 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]
I am trying this since, apparently I want the remote file structure to match the local one.
Why is it failing in the second attempt?
It it because for (some inherent reason) rsync
cannot create any other dir than the leaf? (my-work
)? In that case I have tried the --relative
option as suggested here but with no success whatsoever.
Add this to your command to create missing directory hierarchy on my-server:
--rsync-path="mkdir -p /home/pantelis/my-work/terragrunt/modules/ && rsync"