Linux – rsync invocation to replace symlinks pointing to source

linuxrsyncsymlink

Currently I'm moving a big filesystem to a new server as the original fileserver is no longer able to handle the filesystem writes.

To make this quick I made symlinks at the target filesystem pointing to the original filesystem.

Initially:
/company/release (mountpoint of the original filesystem)

After migration:
/company/release.old (points to original filesystem after automount map update)
/company/release (points to new fileserver/filesystem after automount map update)

In /company/release there are symlinks like the following:
/company/release/product-1.0.tar.gz -> /company/release.old/product-1.0.tar.gz
/company/release/product-1.0 -> /company/release.old/product-1.0 (this is a tree of files)

Using symlinks allowed me to move the writes to the new filesystem quickly.
Now I'd like to slowly migrate the existing files and directories to the new filesystem.

The problem I'm running into is that since the symlinks point back at the original files rsync doesn't see any difference and so it doesn't actually copy the file(s) or directory(s) and remove/overwrite the symlinks.

Is there a set of rsync flags which will do what I want?

Best Answer

From the manpage:

        -L, --copy-links            transform symlink into referent file/dir