Last active
May 11, 2023 21:13
-
-
Save keithel/32630e3da37538ce7adaa01da7154878 to your computer and use it in GitHub Desktop.
Testing if rsync on macOS will properly synchronize xattrs, ACLs, and hard links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -u | |
T=$(echo ${TMPDIR}rsync_test*) | |
if [[ -e $T ]]; then | |
TMP_DIR=$T #"$TMPDIR/rsync_test*" | |
cd $TMP_DIR | |
rm -Rf a b ls_a_out ls_b_out | |
else | |
TMP_DIR=$(mktemp -d -t rsync_test) | |
fi | |
cd $TMP_DIR | |
mkdir a | |
echo "This is a quarantined file" > a/quarantine | |
xattr -w com.apple.quarantine '0002;Safari;https://example.com/;' a/quarantine | |
echo "This is a file with an ACL" > a/acl | |
chmod +a "$USER allow write" a/acl | |
ln -s quarantine a/symlink | |
ln a/acl a/hardlink | |
rsync -r -a -H -E a/ b | |
ls -le@ a > ls_a_out 2>&1 | |
ls -le@ b > ls_b_out 2>&1 | |
diff ls_a_out ls_b_out | |
echo "Created rsync test files in $TMP_DIR." | |
echo "You can see the xattr, acl, symlink and hardlink using:" | |
echo " ls -le@ $TMP_DIR/a" | |
echo "$TMP_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
macOS Monerey 12.6.3
rsync version 2.6.9 protocol version 29
this version of rsync does not preserve hardlinks even with -H which should preserve them, and does not preserve apple extended attributes.
In fact, with -H, it doesn't even try to copy the hard link at all.