tar not archiving all my files

Joined
Jun 15, 2013
Messages
6
Reaction score
0
Points
1
I wanted to test some potential destructive code on a directory and all its subdirectories. So, I tarballed it and then made a copy from the tarball in a space where my code wouldn't accidentally obliterate anything that I really wanted to keep. My code seemed to work except that I noticed that certain files were not put into the tarball.

This is what I originally did:

Code:
 tar -czf mydirectory.tar.gz directory

In the safe location I then did the following:

Code:
 tar -xzf mydirectory.tar.gz

I ran a recursive diff on the archived and original directories. This showed that certain files where missing.

It seems that any file named .__<name>__ were not recorded in the archive. For example,

Code:
.__quiz__

or

Code:
.__example__.

What is tar skipping over these files? How do I get tar to include them? What other files might tar not record?

Even if I ran tar in verbose mode, there was no message that things were being skipped over.

UPDATE

I installed "gnu's" version of "tar" and that works as expected. Everything is correctly archived.

So, why doesn't the natively installed "tar" do the right thing?
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
From man tar:
o Archive entries can have pathnames that include .. components. By default, tar will not extract files containing
.. components in their pathname.

Possibly tar will not extract dot files?
 
OP
Z
Joined
Jun 15, 2013
Messages
6
Reaction score
0
Points
1
My other hidden files, "dot<name>", are all successfully copied. Only "<dot><underscore><name>" are not being copied.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Any file that begins with <dot> is a hidden file, the characters after it, underscore and all don't matter..tar will happily save them and restore them..

Can you try
Code:
tar -ztvf directory.tar.gz | grep <name>
 
OP
Z
Joined
Jun 15, 2013
Messages
6
Reaction score
0
Points
1
That's what I'm doing. "tar" is copying all my hidden files EXCEPT
Code:
.__<name>__
files. I'm asking why this is.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
My command just lists the contents of the tarball to see if it even created it properly...I'm not on my iMac right now, but on my Linux machine I get:

$ ls -la
total 8
drwxrwxr-x 2 <me> <me> 4096 Jul 2 15:34 .
drwxrwxr-x 3 <me> <me>4096 Jul 2 15:33 ..
-rw-rw-r-- 1 <me> <me> 0 Jul 2 15:33 bar
-rw-rw-r-- 1 <me> <me> 0 Jul 2 15:33 foo
-rw-rw-r-- 1 <me> <me> 0 Jul 2 15:33 .foo
-rw-rw-r-- 1 <me> <me> 0 Jul 2 15:34 ._foobar_
$ cd ..
$ tar -zcf test.tar.gz test
$ tar -ztvf test.tar.gz
drwxrwxr-x <me>/<me> 0 2013-07-02 15:34 test/
-rw-rw-r-- <me>/<me> 0 2013-07-02 15:33 test/.foo
-rw-rw-r-- <me>/<me> 0 2013-07-02 15:33 test/foo
-rw-rw-r-- <me>/<me> 0 2013-07-02 15:33 test/bar
-rw-rw-r-- <me>/<me> 0 2013-07-02 15:34 test/._foobar_
$ tar -ztvf test.tar.gz | grep foobar
-rw-rw-r-- <me>/<me> 0 2013-07-02 15:34 test/._foobar_
 
OP
Z
Joined
Jun 15, 2013
Messages
6
Reaction score
0
Points
1
I know it works on Linux. Why not on a Mac?

I installed "gnu"'s version of "tar" and that works as expected and archives all my files.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
I'm thinking maybe Apple's version is set up to not copy files with ._ so it wont copy files like ._DStore and such. I could be wrong, just thinking off the top of my head.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top