3

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?

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
Yarden
  • 496
  • 1
  • 5
  • 16

1 Answers1

5

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

Yarden
  • 496
  • 1
  • 5
  • 16
  • 3
    Thanks for this, the man page clearly says "by default they're all stored", but in practice you must include the --xattrs-include=* for it to work as expected. :-/ –  Jun 29 '18 at 18:22
  • Are you sure? I'm using gnu tar 1.30 and when creating the tarball I only need to set `--xattrs` but when extracting it, I need `--xattrs --xattrs-include='*'`. Can you confirm? – josch Jan 13 '20 at 16:19
  • @josch: I can confirm for tar version Ubuntu20.04/1.30+dfsg-7ubuntu0.20.04.2 (GNU tar 1.30) and for Ubuntu22.04/1.34+dfsg-1build3 (GNU tar 1.34): It is sufficient for creation to add either `--xattrs` or `--xattrs-include='*'`. -- But for extraction you need at least `--xattrs-include='*'`. – Klaus Feb 25 '23 at 14:21