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.69k stars 325 forks source link

xattr in rsync are mapped differently than via SMB โ€” NAS runs Samba with Mac friendly module vfs_fruit #337

Open porg opened 2 years ago

porg commented 2 years ago

Use Case & User Goals

Problem

  1. rsync --xattr ~/path/ nas.local::Shared-rsync/path/ (sender on Mac, receiver on NAS) maps the xattr differently
  2. than when copying from the Mac to a SMB mounted share (served by Samba with the Mac friendly vfs_fruit module)
    • 2a) CLI: cp ~/path/file.txt /Volumes/Shared/path/
    • 2b) GUI: In the Finder drag-n-drop file.txt from local ~/path/ to the mounted SMB share /Volumes/Shared/path/

Environment

MacBook Pro (Mid 2014)

Odroid Home Cloud 2 โ€” Single Board Computer (SBC) acting as a Network Attached Storage (NAS)

/etc/samba/smb.conf ๐Ÿ‘ˆ Click to expand ``` ini # This file is auto-generated by openmediavault (https://www.openmediavault.org) # WARNING: Do not edit this file, your changes will get lost. #======================= Global Settings ======================= [global] workgroup = WORKGROUP server string = %h server dns proxy = no log level = 2 log file = /var/log/samba/log.%m max log size = 1000 logging = syslog panic action = /usr/share/samba/panic-action %d encrypt passwords = true passdb backend = tdbsam obey pam restrictions = no unix password sync = no passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . pam password change = yes socket options = TCP_NODELAY IPTOS_LOWDELAY guest account = nobody load printers = no disable spoolss = yes printing = bsd printcap name = /dev/null unix extensions = yes wide links = no create mask = 0777 directory mask = 0777 use sendfile = yes aio read size = 16384 aio write size = 16384 time server = no wins support = no multicast dns register = no # Special configuration for Apple's Time Machine # Coming from GUI autoconfig fruit:aapl = yes # Coming from GUI autoconfig # Extra options # OMV default extra options min receivefile size = 16384 write cache size = 524288 getwd cache = yes socket options = TCP_NODELAY IPTOS_LOWDELAY # Recommendations from # https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X # man vfs_fruit min protocol = SMB2 ea support = yes vfs objects = fruit streams_xattr # https://support.apple.com//HT207128 # would recommended "catia fruit streams_xattr". Did not try that yet. fruit:aapl = yes # Manually by me in extra options of GUI fruit:metadata = stream fruit:posix_rename = yes fruit:veto_appledouble = no fruit:nfs_aces = no fruit:wipe_intentionally_left_blank_rfork = yes fruit:delete_empty_adfiles = yes #======================= Share Definitions ======================= [Shared] path = /srv/dev-disk-by-label-share/Shared/ guest ok = no guest only = no read only = no browseable = yes inherit acls = yes inherit permissions = no ea support = no store dos attributes = no vfs objects = # Coming from GUI autoconfig. Afraid this nullifies. printable = no create mask = 0664 force create mode = 0664 directory mask = 0775 force directory mode = 0775 hide special files = yes follow symlinks = yes hide dot files = no # These seem to be derived from the settings for the share folder by the autoconfig: valid users = "wife","me" invalid users = @"kids" read list = "wife" write list = "me" vfs objects = fruit streams_xattr # Hence manually aded by me in extra options of GUI. ```

Background Info

RFC 8276 โ€” File System Extended Attributes in NFSv4 (December 2017)

MacOS stores the Finder tags in an xattr named com.apple.metadata:_kMDItemUserTags as a binary PLIST.

HEX/plaintext output of xattr com.apple.metadata:_kMDItemUserTags ๐Ÿ‘ˆ Click to to see the raw BPLIST value in the xattrs ``` $ xattr -l ~/mac/path/8.txt # With Finder Tag "โ€ขTODO" & also having a red label color. com.apple.FinderInfo: 00000000 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000020 com.apple.metadata:_kMDItemUserTags: 00000000 62 70 6C 69 73 74 30 30 A1 01 67 20 22 00 54 00 |bplist00..g ".T.| 00000010 6F 00 64 00 6F 00 0A 00 36 08 0A 00 00 00 00 00 |o.d.o...6.......| 00000020 00 01 01 00 00 00 00 00 00 00 02 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00 00 00 19 |...........| $ xattr -l ~/mac/path/15.txt # With Finder Tag "Artwork" without any color. com.apple.metadata:_kMDItemUserTags: 00000000 62 70 6C 69 73 74 30 30 A1 01 57 41 72 74 77 6F |bplist00..WArtwo| 00000010 72 6B 08 0A 00 00 00 00 00 00 01 01 00 00 00 00 |rk..............| 00000020 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000030 00 00 00 12 |....| 00000034 $ xattr -l ~/mac/path/15.txt # Meanwhile tag "Automation" was added to the end. com.apple.metadata:_kMDItemUserTags: 00000000 62 70 6C 69 73 74 30 30 A2 01 02 57 41 72 74 77 |bplist00...WArtw| 00000010 6F 72 6B 5A 41 75 74 6F 6D 61 74 69 6F 6E 08 0B |orkZAutomation..| 00000020 13 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 |................| 00000030 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000040 1E |.| 00000041 $ xattr -l ~/mac/path/15.txt # Meanwhile tag "Billing" was inserted at start. com.apple.metadata:_kMDItemUserTags: 00000000 62 70 6C 69 73 74 30 30 A3 01 02 03 57 42 69 6C |bplist00....WBil| 00000010 6C 69 6E 67 57 41 72 74 77 6F 72 6B 5A 41 75 74 |lingWArtworkZAut| 00000020 6F 6D 61 74 69 6F 6E 08 0C 14 1C 00 00 00 00 00 |omation.........| 00000030 00 01 01 00 00 00 00 00 00 00 04 00 00 00 00 00 |................| 00000040 00 00 00 00 00 00 00 00 00 00 27 |..........'| 0000004b ```

Debian's xattr -l crashes with UnicodeDecodeError for com.apple.metadata:_kMDItemUserTags

Problem in detail

Ad 2) When using rsync <my-arguments> ~/path/ /Volumes/SMB-Mounted-Share/path/

Ad 1) When using rsync <my-arguments> ~/path/ nas.local::Shared-rsync/path/

Followup

SEIAROTg commented 2 months ago

I think the mapping is configurable in Samba to match rsync's behavior.

https://www.samba.org/samba/docs/current/man-html/vfs_streams_xattr.8.html

porg commented 2 months ago

How exactly would that help?

I forgot everything meanwhile, my lengthy/detailed post is 2 years old.

By which concrete mappings could one improve the use case rsync is used both as sender on the Mac and receiver on the NAS ?

SEIAROTg commented 2 months ago

You can set the prefix to match rsync (as sender & receiver) and drop the suffix.

streams_xattr:prefix = user.
streams_xattr:store_stream_type = no

It also works for your first usage (rsync into SMB mount). However, when doing that rsync might fail (unrelated to these settings) when one xattr is a prefix of another, due to a bug in Apple SMB client implementation.

porg commented 1 month ago

Thanks. As I do not have that use case anymore (too often) I currently don't have the time to try it out and give feedback on it. But I gladly come back here, should I need it at a later time. Thanks for having taken the time!