I’m trying to rsync to a remote folder which already has the files. I’m pretty sure the contents are the same, as Syncthing has checked them before. After Syncthing I changed their permission, ownership and SELinux context. Now However the transfer is basically sending every file. Is this supposed to happen?
Wait, the attributes in destination files aren’t changed. But the destination was specified correctly as far as I can see… Is there a way to check that rsync sent the file to the right place?
It depends on the options you pass (and the order that you pass them). You probably need to add --no-perms, --no-owner, --no-group, and --no-xattrs (for SELinux). (And maybe --no-times.)
-a (archive mode) turns on all of those things. You’ll need to add the options I listed after-a to turn them back off (or use more fine-grained flags than -a to construct your command). Anyway, it’s all in the man page man rsync.
I’m not sure what you are suggesting, did you mean “it is supposed to happen”? Ok I guess…
But still -a implies attributes will be synced which didn’t happen?
I guess I misunderstood your question. I had read it as saying that changing the attributes was causing the files to be resent and you didn’t want it to do that.
There might be a hint as to what is going on in the documentation for the --times flag:
–times, -t
This tells rsync to transfer modification times along with the files and update them on the remote system. Note that if this option is not used, the optimization that excludes files that have not been modified cannot be effective; in other words, a missing -t (or -a) will cause the next transfer to behave as if it used --ignore-times (-I), causing all files to be updated (though rsync’s delta-transfer algorithm will make the update fairly efficient if the files haven’t actually changed, you’re much better off using -t).
Skimming the man page, it looks like the --checksum flag might cause rsync to use hashes instead of modification times and file sizes to determine what needs to be transferred. You might give that option a try and see if it does what you want.
Oh, rsync has a well-known issue where you have to add a trailing / to the source directory to avoid it duplicating the content in a subdirectory of the destination path on the second run. See the USAGE section of the man page for an explanation.
Edit: But to more directly answer your question, yes, rsync has --verbose and --dry-run flags that allow you to see what would be done by a given command without actually doing it.