Mac Forums

Mac Forums (
-   OS X - Operating System (
-   -   tar not archiving all my files (

zapatafa 07-02-2013 03:11 PM

tar not archiving all my files
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:


tar -czf mydirectory.tar.gz directory
In the safe location I then did the following:


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,




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.


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?

cradom 07-02-2013 03:25 PM

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?

zapatafa 07-02-2013 03:30 PM

My other hidden files, "dot<name>", are all successfully copied. Only "<dot><underscore><name>" are not being copied.

Raz0rEdge 07-02-2013 03:35 PM

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

tar -ztvf directory.tar.gz | grep <name>

zapatafa 07-02-2013 03:45 PM

That's what I'm doing. "tar" is copying all my hidden files EXCEPT

files. I'm asking why this is.

Raz0rEdge 07-02-2013 03:52 PM

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_

zapatafa 07-02-2013 04:11 PM

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.

cradom 07-02-2013 06:10 PM

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.

All times are GMT -4. The time now is 08:03 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.