RsyncProject / rsync

An open source utility that provides fast incremental file transfer. It also has useful features for backup and restore operations among many other use cases.
https://rsync.samba.org
Other
2.74k stars 328 forks source link

macOS xattrs problem with --remove-source-files #541

Open akikostas opened 11 months ago

akikostas commented 11 months ago

We attempt to sync two directories, the source "a" is to be synced to target "b".

We have a document called "file" on the source with certain metadata like _kMDItemUserTags. On the destination we have the same "file" without this specific metadata. All else is identical regarding the file.

If we simply rsync without --remove-source-files, then the sync completes as expected. The destination file is updated with the metadata of the source.

If instead we rsync and --remove-source-files, mimicking a scenario when we want to move files to a new directory, then the process returns an error. Metadata is not properly added on the destination files.

On the original "file" I had a blue-colored macOS tag with the name "complete". The destination ended up having a blue tag with the default name "blue". So my rsync gets "corrupted" when I use the --remove-source-files.

Here is the result from terminal: Note that I use both the source and destination on APFS for 100% compatibility in my transfers.

`freeman@ketaab _terminal % rsync -ahvEX --progress --remove-source-files /Users/freeman/Documents/_terminal/a/ /Users/freeman/Documents/_terminal/b/ sending incremental file list ./ rsync: [sender] get_xattr_data: lgetxattr("/Users/freeman/Documents/_terminal/a/file","com.apple.metadata:_kMDItemUserTags",0) failed: No such file or directory (2) failed to re-read xattr com.apple.metadata:_kMDItemUserTags for file

sent 211 bytes received 44 bytes 510.00 bytes/sec total size is 0 speedup is 0.00 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1356) [sender=3.2.7]`

realsimix commented 9 months ago

I see the same errors on Linux with rsync -aHAX --max-alloc=0 --remove-source-files:

rsync: [sender] get_xattr_data: lgetxattr("/etc/systemd/system/basic.target.wants/microcode.service","security.selinux",0) failed: No such file or directory (2)
failed to re-read xattr security.selinux for etc/systemd/system/basic.target.wants/microcode.service

I guess that the source file gets removed too early in the process and therefore is not available when it "re-read xattr" somehow.

Regards, Simon