Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running tar as root like this:

cd /
tar --create                    \
    --verify                    \
    --exclude-backups           \
    --exclude-caches            \
    --auto-compress             \
    --file /tmp/home.tar.gz     \
    --exclude=/home/elena/.gvfs \
    home

tar outputs:

tar: home/elena/.gvfs: Cannot stat: Permission denied

I would expect the .gvfs[1] directory to be ignored completely. Why is GNU tar running stat over it?

As to why I'm using /home/elena/.gvfs - an absolute path - to match the .gvfs directory, it is because - to my knowledge - there is no other way to select single directories for exclusion without excluding matching subdirectories at any level as well.

I've tried putting the --exclude line after home, to take possible quirks in different versions of tar into account, but that changes nothing.

Thanks for your attention.

GNU tar version: 1.23

--

[1] ~/.gvfs is a way to access the Gnome Virtual File System I'm skipping it because I know it can't be accessed, and it doesn't make sense to archive it. I still wonder why tar doesn't skip it completely.

share|improve this question
    
What are the permissions on /home/elena/.gvfs? –  MattDMo Jul 12 '13 at 14:32
    
@MattDMo: I have no idea: even ls -l /home/elena/.gvfs as root fails because of denied access. However, I know that .gvfs is a way to access the Gnome Virtual File System: en.wikipedia.org/wiki/GVFS I'm skipping it because I know it can't be accessed, and it doesn't make sense to archive it. –  Elena Jul 12 '13 at 14:57
    
Try running ls -al /home/elena and let us know what the entire .gvfs line says. This way, you're not trying to read the contents of .gvfs as ls -l /home/elena/.gvfs is doing. Also, can you read /home/elena/.gvfs as user elena, not root? –  MattDMo Jul 12 '13 at 17:22
    
Run as root, permission denied again: ls: cannot access /home/elena/.gvfs: Permission denied. And the .gvfs line reads: d?????????? ? ? ? ? ? .gvfs It's the only item in the output of ls that looks weird. –  Elena Jul 12 '13 at 17:51
    
Are those question marks? Sorry, I'm on XP (Firefox 22) and what you posted just showed up as d?????????? ? ? ? ? ? (approximately, I just typed that in...) –  MattDMo Jul 12 '13 at 18:35

1 Answer 1

tar: home/elena/.gvfs: Cannot stat: Permission denied

Notice that the error message doesn't include a leading slash. Try --exclude=home/elena/.gvfs without the slash.

share|improve this answer
    
Thank you, but I can't. Otherwise the pattern could match subdirectories at every level, and I don't want that. –  Elena Jul 12 '13 at 13:07
    
Then you can't exclude it. –  tripleee Jul 12 '13 at 13:09
    
Hence tar doesn't allow for fine-grained control on what directories and files end up in an archive? –  Elena Jul 12 '13 at 13:26
    
Not by itself, as far as I understand the documentation. The workaround is to find | grep - v stuff | xargs tar or some approximation of that. –  tripleee Jul 12 '13 at 14:23
2  
@Elena Try also adding option --anchored. Than would match the initial part of the path name even without slash. –  eppesuig Jul 12 '13 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.