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.
1. Are there rsync
flags which can achieve the desired result?
2. If not, can anyone think of a straightforward solution?
Asked by Lagrangian
(437 rep)
Nov 5, 2016, 06:23 AM
Last activity: Jul 23, 2025, 04:36 AM
Last activity: Jul 23, 2025, 04:36 AM