openrsync icon indicating copy to clipboard operation
openrsync copied to clipboard

Bug Report: rsync does not report symlink target changes in --stats or --itemize-changes

Open schneems opened this issue 6 months ago • 1 comments

Expected

If running rsync causes a directory to change, I expect that change to show up in the output as well under --itemize-changes.

Actual

The symlink in the destination is updated on disk, but rsync reports "Number of files transferred: 0" and --itemize-changes produces no output. This makes it appear as if nothing was changed, even though the symlink was updated.

Steps to Reproduce

Create a source and destination folder. Both have a symlink but with different contents:

mkdir -p /tmp/3ab8a3f82068f55f5ea8e5b72b09b6cf; cd /tmp/3ab8a3f82068f55f5ea8e5b72b09b6cf
mkdir -p source dest

echo "outside content" > outside_file.txt
ln -sf ../outside_file.txt source/symlink.txt
ln -sf differentcontents dest/symlink.txt

Before rsync:

$ ls -laR dest/ source/
./dest:
total 0
drwxr-xr-x@ 3 rschneeman  wheel   96 Jul 10 21:44 .
drwxr-xr-x@ 5 rschneeman  wheel  160 Jul 10 21:44 ..
lrwxr-xr-x@ 1 rschneeman  wheel   17 Jul 10 21:44 symlink.txt -> differentcontents

./source:
total 0
drwxr-xr-x@ 3 rschneeman  wheel   96 Jul 10 21:44 .
drwxr-xr-x@ 5 rschneeman  wheel  160 Jul 10 21:44 ..
lrwxr-xr-x@ 1 rschneeman  wheel   19 Jul 10 21:44 symlink.txt -> ../outside_file.txt

Run rsync

$ rsync --archive --itemize-changes --verbose source/ dest/
Transfer starting: 2 files

sent 129 bytes  received 20 bytes  135454 bytes/sec
total size is 19  speedup is 0.13

After rsync:

$ ls -laR dest/ source/
./dest:
total 0
drwxr-xr-x@ 3 rschneeman  wheel   96 Jul 10 21:44 .
drwxr-xr-x@ 5 rschneeman  wheel  160 Jul 10 21:44 ..
lrwxr-xr-x@ 1 rschneeman  wheel   19 Jul 10 21:44 symlink.txt -> ../outside_file.txt

./source:
total 0
drwxr-xr-x@ 3 rschneeman  wheel   96 Jul 10 21:44 .
drwxr-xr-x@ 5 rschneeman  wheel  160 Jul 10 21:44 ..
lrwxr-xr-x@ 1 rschneeman  wheel   19 Jul 10 21:44 symlink.txt -> ../outside_file.txt

The contents are different after the rsync but there was no indication in the output that symlink.txt -> ../outside_file.txt was changed.

Version Information

$ rsync --version
openrsync: protocol version 29
rsync version 2.6.9 compatible

Context

The reason this is important for me, is I'm using --dry-run to verify that two directories are identical. I want to have a maximal comparison including filetimes and permissions, etc. I get that from rsync except for this edge case where the symlink exists, but it's different. I know that I can have rsync resolve the symlink and replace it with the actual file contents, but that's not the behavior I want.

schneems avatar Jul 11 '25 03:07 schneems

I was able to get this working via brew install rsync (on a mac) which fixes the problem. I'm unsure how to install the latest version of openrsync on my mac to test if the problem persists in the latest release or not.

schneems avatar Jul 11 '25 03:07 schneems