How to Preserve File Attributes with rsync –fake-super: Solving “Operation not supported” Errors


8 views

When working with rsync's --fake-super option, many administrators encounter the frustrating "Operation not supported (95)" error when attempting to restore file attributes. This typically occurs during cross-platform backups or when restoring to filesystems with different extended attribute support.

The --fake-super flag is rsync's solution for preserving permissions and ownership when transferring files between systems where you don't have root access. Instead of trying to set real Unix permissions (which requires root), it stores them as extended attributes (xattrs):

# Original backup command
rsync -avz --fake-super /source/path user@remote:/backup/location

# Restoration attempt
rsync -avz --fake-super user@remote:/backup/location /restore/path

The error occurs because:

  • Not all filesystems support extended attributes (xattrs)
  • Implementation varies between ext3/ext4/HFS+/APFS
  • Default mount options might disable xattr support

Here are tested approaches that work across different platforms:

# Solution 1: Ensure xattr support is enabled on target
mount -o remount,user_xattr /restore/path

# Solution 2: Alternative rsync approach for Linux targets
rsync -avz --numeric-ids --usermap=:$(id -u) --groupmap=:$(id -g) \
      --chmod=ugo=rwX source/ dest/

# Solution 3: For HFS+ on macOS
sudo chmod -R +a "user:backupuser allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown" /backup/location

For ext3/ext4:

tune2fs -o user_xattr /dev/sdX
mount -o remount,user_xattr /path

For HFS+ (macOS):

diskutil enableOwnership /Volumes/Backup
sudo chflags -R nouchg,noschg /backup/location

Always test your setup:

# Create test file
touch testfile
chmod 4755 testfile
setfattr -n user.test -v "testvalue" testfile

# Backup and restore
rsync -avX --fake-super testfile backup_location/
rsync -avX --fake-super backup_location/testfile restored_file/

# Verify attributes
getfattr -d restored_file/testfile
ls -l restored_file/testfile

When xattrs simply won't work:

# Using tar as intermediate format
tar -cvf - --xattrs --xattrs-include='*' /source | ssh user@remote "tar -xvf - -C /backup"

# Using rsync without --fake-super (requires root)
rsync -avzAHX --rsync-path="sudo rsync" source/ user@remote:/backup

When attempting to preserve file metadata during rsync operations between different filesystems, many admins encounter the frustrating "failed to write xattr" error. This typically happens when:

  • Transferring between different OS platforms (Linux → macOS or vice versa)
  • Using filesystems with different xattr implementations (ext3/4 → HFS+)
  • Running rsync versions that handle --fake-super differently

The --fake-super flag tells rsync to store privileged attributes in extended attributes (xattrs) rather than requiring root privileges during transfer. This is particularly useful when:

# Example of normal privileged backup (requires root both ends)
rsync -aAXv /source/ user@remote:/backup/

# Versus fake-super approach
rsync -aAXv --fake-super /source/ user@remote:/backup/

For reliable attribute preservation across different systems:

# Backup command with full attribute handling
rsync -aHAXxv --numeric-ids --fake-super \
      --delete --stats /source/ user@remote:/backup/

# Restoration command with proper xattr support
rsync -aHAXxv --fake-super \
      user@remote:/backup/ /restore/path/

Different filesystems require specific mounting options to support xattrs:

# For ext3/4 filesystems:
mount -o user_xattr /dev/sdX /mnt

# For HFS+ on macOS:
mount -o nobrowse,usrquota,grpquota /dev/diskXsY /mnt

# For XFS:
mount -o attr2 /dev/sdX /mnt

If you still encounter xattr errors, try these diagnostic steps:

# Check xattr support on target filesystem
getfattr -d -m - /path/to/testfile

# Verify rsync's xattr capability
rsync --version | grep xattrs

# Test basic xattr operations
setfattr -n user.test -v "testvalue" testfile
getfattr -d testfile

For systems where xattrs simply won't work:

# Option 1: Use tar as intermediate container
(cd /source && tar --xattrs -cf - .) | \
ssh user@remote "cd /backup && tar --xattrs -xf -"

# Option 2: Store metadata separately
rsync -aX --fake-super --metadata-only /source/ user@remote:/meta/
rsync -a /source/ user@remote:/data/

Here's a complete backup script handling Linux→macOS transfers:

#!/bin/bash
SOURCE="/var/www"
DEST="user@mac:/Backups/web"
RSYNC_OPTS="-aHAXxv --numeric-ids --fake-super --delete"

# Verify xattr support first
if ! touch /tmp/xattr_test && \
   setfattr -n user.test -v 1 /tmp/xattr_test 2>/dev/null; then
    echo "ERROR: xattr not supported on $SOURCE" >&2
    exit 1
fi

# Perform the actual transfer
if rsync $RSYNC_OPTS --stats "$SOURCE" "$DEST"; then
    logger "Backup completed successfully"
else
    logger "Backup failed with exit code $?"
fi