It doesn't need to be done by rsync, but it would be nice not have to write a script to do this, and rsync is very close to what I want.
rsync -a (or -l) can preserve symlinks, and -L can dereference symlinks and copy it as if it is normal file/dir. However, is it possible to keep the symlink, and also copy the files/directories the links points to?
Here's an example. Say we have this folder hierarchy:
dirA/link_to_file -> ../dirB/file
dirA/link_to_dir -> ../dirC
dirB/file
dirB/not_this_file
dirC/file
dirC/file2
dirD/others
and when I do rsync -aR dirA dest (or something else), I'd like to have exactly these appear in dest:
dirA/link_to_file -> ../dirB/file
dirA/link_to_dir -> ../dirC
dirB/file
dirC/file
dirC/file2
Is this possible with rsync? Thank you.
Let's assume symlinks having absolute path or pointing to outside the source directory can be ignored.

dirA/linkis a symlink to../dirB/file, then this should be handled as copyingdirB/filetodest/dirB/fileanddirA/linktodest/dirA/link. What ifdirA/linkis a link to../../another_file? What happens, in general, ifdirA/linkpoints to a directory that is higher up in the directory tree?a -> b,b -> c/foo,c -> d/e: a request to copyashould also copyb,c,c/foo,d,d/eandd/e/foo).