Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Operating System (http://www.mac-forums.com/forums/os-x-operating-system/)
-   -   tar not archiving all my files (http://www.mac-forums.com/forums/os-x-operating-system/300626-tar-not-archiving-all-my-files.html)

zapatafa 07-02-2013 04: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:

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?

cradom 07-02-2013 04: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 04:30 PM

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

Raz0rEdge 07-02-2013 04: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
Code:

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

zapatafa 07-02-2013 04:45 PM

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

.__<name>__
files. I'm asking why this is.

Raz0rEdge 07-02-2013 04: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:

Quote:

$ 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 05: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 07: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 04:32 PM.

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