Ny way to rsync absolute symlinks alone

rsyncsymlink

I want to sync a big folder hierarchy between two machines.
I want to copy the contents of the symlinks if they are absolute, for eg it points to /some/folder/someFile
I want to retain the symlinks if they are relative, for eg, it points to ../../somefolder
How do I do this?

Edit:
Basically I try to avoid recursion.
I tried –copy-unsafe-links option, it copies absolute links but skips internal or relative links, does not retain the link.

Best Answer

I think you should be able to use the --copy-unsafe-links option on rsync to copy file data where the symlink points outside of the synchronized folder space but sends just the symlink when the file pointed to is also being synced. This is in addition to --links (-l, it's included in -a) to copy relative symlinks inside the copied hierarchy as symlinks.

If that isn't fine tuned enough, you will probably have to create a list of links you do and don't want to send using find and pass those as input to rsync in the form of include/exclude lists.

Related Question