Search code examples
tarxattr

Tar not preserving extended attributes of 'trusted' namespace


Explanation

I am using tar for creating an archive containing a folder and some of its files have extended attributes.

Including these:

  • trusted.size=5
  • trusted.test

I created and extracted the archive this way:

sudo tar --xattrs --xattrs-include='trused\.' -cf file.tar archive_folder .
sudo tar --xattrs --xattrs-include='trused\.' -xvf file.tar -C extracted_folder

The problem

After extracting the files I try to view the attributes:

sudo getfattr -n trusted.size file

But the attributes are always missing. How do I preserve those attributes?


Solution

  • After a little play with the tar creation and extraction lines, iv'e found that tar --xattrs --xattrs-include=* Must be used in order to save and extract xattributes