This is related to this question but I don't think the answer exactly applies here.
I have two servers that sync directories between each other. These directories contain files and symlinks. On server B, I sync from server A with this command:
rsync -auv A:dir/ dir/
What I want: Any file or symlink on A that is different and newer than the corresponding file or symlink on B is synced.
What actually happens: Any file on A that is different and newer than the corresponding file on B is synced. Any symlink on A that is different than the corresponding symlink on B is synced, regardless of timestamp.
The man page for
rsync has this (emphasis mine):
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.) Note that this does not affect the copying of symlinks or other special files.
So this is the expected behavior. Why is this? Is there a way around it? Or, is there an alternate solution to the overall goal, which is to get these directories in sync after a server has been offline for some time and missed data?
My rsync version is
Example: I set up 2 directories,
Bdir, each containing a file and a symlink with different contents:
$ ls -l Adir/ Bdir/ Adir/: total 0 -rw-r--r-- 1 kevin kevin 5 May 27 18:00 file lrwxrwxrwx 1 kevin kevin 10 May 27 18:00 symlink -> /some/file Bdir/: total 0 -rw-r--r-- 1 kevin kevin 6 May 27 17:00 file lrwxrwxrwx 1 kevin kevin 16 May 27 17:00 symlink -> /some/other/file
rsync --dry-run -auv Adir/ Bdir/ outputs this:
sending incremental file list ./ file symlink -> /some/file sent 101 bytes received 21 bytes 244.00 bytes/sec total size is 15 speedup is 0.12 (DRY RUN)
Which is what I expect. It copies (or would if not in dry run) both the file and symlink because they are newer. However running
rsync --dry-run -auv Bdir/ Adir/ outputs this:
sending incremental file list ./ symlink -> /some/other/file sent 104 bytes received 18 bytes 244.00 bytes/sec total size is 22 speedup is 0.18 (DRY RUN)
Bdir/symlink is older than
Adir/symlink it still gets syned.