Suppose I have a directory on a local machine, behind a firewall:
local:/home/meee/workdir/
And a directory on a remote machine, on the other side of the firewall:
remote:/a1/a2/.../aN/one/two/
remote:/a1/a2/.../aN/one/dont-copy-me{1,2,3,...}/
...such that N
>= 0.
My local machine has a script that uses rsync
. I want this script to copy only one/two/
from the remote machine for a variable-but-known 'N' such that I end up with:
local:/home/meee/workdir/one/two/
If I use rsync remote:/a1/a2/.../aN/one/two/ ~/workdir/
, I end up with:
local:/home/meee/workdir/two/
If I use rsync --relative remote:/a1/a2/.../aN/one/two/ ~/workdir/
, I end up with:
local:/home/meee/workdir/a1/a2/.../aN/one/two/
Neither one of these is what I want.
rsync
flags which can achieve the desired result?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/
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments