Looks like when tar trying to restore xattrs it use path to file relative to current directory, ignoring -C option. Setup test environment: ~ $ mkdir -p tar-xattr-bug/{src,dst} ~ $ cd tar-xattr-bug/ ~/tar-xattr-bug $ touch src/test ~/tar-xattr-bug $ setfattr -n user.key -v val src/test ~/tar-xattr-bug $ getfattr -d src/test # file: src/test user.key="val" Try to copy from src/ to dst/ with xattrs: ~/tar-xattr-bug $ cd src/ ~/tar-xattr-bug/src $ tar --xattrs -cf - ./ | tar -C ../dst/ -xvpf - ./ ./test tar: ./test: Cannot open: File exists tar: Exiting with failure status due to previous errors ~/tar-xattr-bug/src $ ls -al ../dst/ total 8 drwxr-xr-x 2 powerman powerman 4096 Nov 18 00:07 . drwxr-xr-x 4 powerman powerman 4096 Nov 18 00:12 .. ~/tar-xattr-bug/src $ Looks like unpacked file ../dst/test was removed by tar because of some internal error. Try again, using another current directory: ~/tar-xattr-bug/src $ cd .. ~/tar-xattr-bug $ find -type f ./src/test ~/tar-xattr-bug $ tar -C src/ --xattrs -cf - ./ | tar -C dst/ -xvpf - ./ ./test ~/tar-xattr-bug $ find -type f ./test ./dst/test ./src/test ~/tar-xattr-bug $ getfattr -d dst/test ~/tar-xattr-bug $ getfattr -d test # file: test user.key="val" Now tar created two files - one in dst/ and second in current directory, and xattrs was applied only to second file. And again, with subdirectory: ~/tar-xattr-bug $ mkdir src/subdir ~/tar-xattr-bug $ mv src/test src/subdir/ ~/tar-xattr-bug $ rm test dst/test ~/tar-xattr-bug $ getfattr -d src/subdir/test # file: src/subdir/test user.key="val" ~/tar-xattr-bug $ find -type f ./src/subdir/test ~/tar-xattr-bug $ tar -C src/ --xattrs -cf - ./ | tar -C dst/ -xvpf - ./ ./subdir/ ./subdir/test tar: ./subdir/test: Cannot setxattr: No such file or directory tar: ./subdir/test: Cannot open: No such file or directory tar: Exiting with failure status due to previous errors ~/tar-xattr-bug $ find -type f ./src/subdir/test ~/tar-xattr-bug $ find -type d . ./dst ./dst/subdir ./src ./src/subdir So, looks like tar again removed dst/subdir/test after it failed to set xattrs on non-existing subdir/test in current directory.
This bug is fixed in tar >=1.27.