Unison and extended file attributes

rsyncunisonxattr

I have two machines, one Debian, one Ubuntu, both on ext4 with extended file attributes enabled in fstab. getfattr and setfattr are installed and work perfectly on both machines locally. However, unison (version 2.40.102) doesn't sync extended file attributes by default.

I googled around and found this blog post with profile settings that are supposed to enable extended attribute sync. So, I changed my profile, and now it looks something like this:

root=/path/to/dir
root=ssh://user@example.com//path/to/dir2
auto=true
batch=true
perms=0
rsync=true
maxthreads=1
retry=3
confirmbigdeletes=false
copythreshold=0
copyprog = rsync -aX --rsh='ssh -p 22' --inplace --compress
copyprogrest = rsync -aX --rsh='ssh -p 22' --partial --inplace --compress
copyquoterem = true
copymax = 1

This profile syncs extended attributes for new files, but when I change extended attributes on a file that has already been synced and execute unison I get:

Nothing to do: replicas have not changed since last sync.

Everything else syncs perfectly, but unison is unaware of the changes in extended attributes. I also tried disabling fastcheck, hoping it would make it check the files in more detail; didn't work. I tried rsync'ing in one direction and it worked perfectly. But I need bi-directional syncing so I'm stuck with unison.

I have looked through the official manual but it only mentions extended file attributes in passing. So my question is this: can this be done with unison? Am I missing something simple here? Alternatively, are there other open source tools that can achieve this? (I'm aware of bsync and bitpocket, but in my preliminary tests they also fail to notice extended file attribute changes).

Best Answer

In case anyone runs into the same issue as I did in the future - unison doesn't work with extended file attributes. One way to go around it is the copyprog + copythreshold=0 hack (see the profile in the original question), but this doesn't solve the problem of unison not noticing changes in xattr's. As I mentioned in one of the comments, even changing the modification time of the file won't make unison sync modified xattr's. Not only that, but it will even erase them the next time that file has its content changed.

The only way I could get bi-directional syncing with extended file attributes to work is to use bsync, change it by adding -X flag to rsync arguments AND change modification time of the file.

This is far from the ideal solution: changing modification time of the file, no Windows support, Python 3 dependency, last commit was last year etc, but that's the only software I found that does the job.

Related Question