Namitha Rao
2007-Apr-11 12:09 UTC
Is There a way to preserve symlink and also copy the actual contents using rsync
Hi On the rsync Server we have rsync path set to say, path= /x/y where 'y' is symlink to some other directory say 'z' on the same machine. Now is there a way to sync 'y' on remote client preserving the symlink as it is and also copy the actual contents from 'z' to say 'z' on the client machine. I have tried using '-l ' option which copies symlink as symlink but the actual contents are not copied on to remote client machine. Is there a way to copy even the contents using rsync? Thanks in Advance Namitha -------------- next part -------------- HTML attachment scrubbed and removed
Matt McCutchen
2007-Apr-27 01:06 UTC
Is There a way to preserve symlink and also copy the actual contents using rsync
On 4/11/07, Namitha Rao <namithajr@gmail.com> wrote:> On the rsync Server we have rsync path set to say, path= /x/y > > where 'y' is symlink to some other directory say 'z' on the same machine. > > Now is there a way to sync 'y' on remote client preserving the symlink as > it is and also copy the actual contents from 'z' to say 'z' on the client > machine.If the module path in the server's configuration file refers to a symlink, the client will see the symlink's target directory as the root of the module; it will never see the symlink itself. Thus, rsync won't help you sync a symlink at a module root; of course, you could write a script yourself that does so. However, if symlinks to directories appear *inside* the module, you can sync both the symlinks and the target directories. Use two passes, one to sync the symlinks themselves and one to follow them in order to sync the targets. If the target directories might not yet exist on the destination, you need an intermediate step to create them. Here's an example of the script you would run on the client: rsync -a server::module/ dest/ find dir -type l -exec bash -c \ 'mkdir -p "$(readlink --canonicalize-missing "$1")"' x {} \; rsync -a --copy-dirlinks --keep-dirlinks server::module/ dest/ Matt