Use the -R (--relative)
option to rsync to preserve the directory structure. Take a look at:
https://serverfault.com/questions/39522/how-to-keep-the-full-path-with-rsync
Here's an example:
[localbox] tree test
test
└── sub1
└── subsub1
├── a
├── b
├── c
├── d
├── e
└── f
[localbox] rsync -avR test/sub1/subsub1 me@my-system:dest_path
sending incremental file list
created directory dest_path
test/
test/sub1/
test/sub1/subsub1/
test/sub1/subsub1/a
test/sub1/subsub1/b
test/sub1/subsub1/c
test/sub1/subsub1/d
test/sub1/subsub1/e
test/sub1/subsub1/f
sent 406 bytes received 185 bytes 394.00 bytes/sec
total size is 0 speedup is 0.00
[localbox] ssh me@my-system
[my-system] tree dest_path
dest_path
`-- test
`-- sub1
`-- subsub1
|-- a
|-- b
|-- c
|-- d
|-- e
`-- f
3 directories, 6 files
Below is cut from the rsync man page:
-R, --relative
Use relative paths. This means that the full path names specified on the command line are sent to the server rather than just
the last parts of the filenames. This is particularly useful when you
want to send several different directories at the same time. For
example, if you used this command:
rsync -av /foo/bar/baz.c remote:/tmp/
... this would create a file named baz.c in /tmp/ on the remote machine. If instead you used
rsync -avR /foo/bar/baz.c remote:/tmp/
then a file named /tmp/foo/bar/baz.c would be created on the remote machine, preserving its full path. These extra path
elements are called "implied directories" (i.e. the "foo" and the
"foo/bar" directories in the above example).