2

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?

3 Answers 3

1

From the manpage:

        -L, --copy-links            transform symlink into referent file/dir
1
  • 1
    That's not quite what I'm looking for. I want to overwrite links on the target side, not copy from the source and make the links into real dir's on the target side.
    – bdbaddog
    Nov 15, 2012 at 23:18
0

The -a argument will do what you want, copy symlinks (among other things) so the destination will be "archival copy" of the source.

NOTE: the -a flag of cp which seems a lot like the rsync -a flag (in that it preserves all the attributes, date and time), DOESN'T remove the target before the copy, so it copies through any existing symlinks off to wherever they point.

Example: *Files a, b, c with strings "one", "two" and "three" in them respectively then have symlink aa pointing to a.*

With cp -a c aa, you will end up with "three" in a which seems really wrong until you realize they are doing POSX, and that means lowest common denominator.

With rsync -a c aa, the symlink aa is replaced with a file containing "three" and file a stays uncorrupted.

0

Use --ignore-times (-I) so that rsync will always copy. Rsync is supposted to compare the destination to the source and optimize the copy. Unfortunately there is no --replace-reflective-symbolic-links option. Rsync always views a link to the source as having content which is identical to the source.

The only way I found to solve this problem is to use find . -type l -exec bash -c '{ z=$(readlink -e "{}"); [[ "$z" ]] && cp -av --remove-destination "$z" "{}"; };' \; which you might need to tweak to meet your needs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .