We are currently using "rsync" to copy a directory recursively. We are moving to a newer platform where "rsync" is not available and have been advised to use "cp" instead. We use the below options in "rsync".
rsync -ak --safe-links src dest
-k --> transforms and copies dir symlinks in source as dir in target
--safe-links --> ignores symlinks that point outside the source tree
We have file symlinks as well within the source tree which we want to retain in the target to avoid bloating the size.
We can manage without an alternative for the "--safe-links" option. I checked the options in the "cp" command and am not able to find anything that matches the "-k" option of rsync. I tried the below options:
cp -rh
cp -rd
cp -rH
But all of them either dereference both file & dir symlinks or retain both of them.
Is there a way to achieve the "-k" option of "rsync" in "cp"? If not "cp", is there any other utility that provides a similar functionality? I want to avoid having to write a custom script just for this copy.
Thanks.