rsync using part of a relative path

For -- relative you have to insert a dot into the source directory path:

rsync -av --relative remote:/a1/a2/.../aN/./one/two ~/workdir/

See the manual:

-R, --relative

[...]

It is also possible to limit the amount of path information that is sent as implied directories for each path you specify. With a modern rsync on the sending side (beginning with 2.6.7), you can insert a dot and a slash into the source path, like this:

             rsync -avR /foo/./bar/baz.c remote:/tmp/

If you are pulling files from an rsync older than v2.6.7, you can do this by taking advantage of rync's --rsync-path option, which is meant to allow you to specify where the rsync command can be found on the remote. However, you can use it to change directory first. Simply,

rsync -aR --rsync-path='cd /a1/a2/.../aN/ && rsync' remote:one/two/ ~/workdir/

Tags:

Rsync