How to force tar to be quiet?

Matthew Seaman m.seaman at infracaninophile.co.uk
Mon Dec 28 10:05:00 UTC 2009


Коньков Евгений wrote:
> Здравствуйте, Matthew.
> 
> Вы писали 27 декабря 2009 г., 20:46:05:
> 
> MS> Коньков Евгений wrote:
>>> Здравствуйте, Freebsd-questions.
>>>
>>> when
>>> tar -cf file.tar /home/*
>>> It always says:
>>> tar: Removing leading '/' from member names
>>>
>>> man tar
>>> -P Preserve pathnames...
>>> But I do not need to preserve. I want to tar without that warning.
>>>
>>> How to force tar to be quiet?
>>>
> 
> MS> Don't give the leading '/' in path names.  Like so:
> 
> MS>    tar -cf file.tar -C / home
> 
> MS>         Cheers,
> 
> MS>         Matthew  
> 
> # tar -cf /home/kes/backup/conf/aaa_etc.tar -C / boot/loader.conf etc/* usr/local/etc/* usr/local/virtwww/*
> tar: No match.

Yep.  As shown, you don't need '*' here.  tar(1) is perfectly capable of recursing
through a directory hierarchy given only the name of the top level directory.

[ * is actually expanded by your shell, rather than tar, so it's trying to match
filenames against your current working directory, and not against the directory
the '-C' switches tar to.] 

> And next does not work as expected:
> # tar -cf /home/kes/backup/conf/aaa_etc.tar -C / boot/loader.conf etc usr/local/etc usr/local/virtwww
> 
> I get:
> boot
> etc
> mysite
> local
> sub
> usr
> virtwww

Hmmm... I can't reproduce this locally.  If I run:

   sudo tar -cf foo.tar -C / etc boot

then I get (as expected) a tarball with the contents of /etc and /boot -- not
only that, but there's nothing printed to stdout/stderr while the command runs.

Are any of the directories concerned symbolic links on your system?  tar(1)
handles sym-links quite carefully given that it's possible to use them to
generate specially crafted tar archives that you can use to trick an unwary
admin into overwriting security sensitive files.  As a rule of thumb, when
specifying directory trees to back-up, try and avoid having any path components
being symbolic links.

> Why local, sub, mysite, virtwww are in ROOT or tar???
> 'local' must be under 'usr'
> 'virtwww' must be under 'local'
> 'mysite' must be under 'virtwww'
> but not in root
> 
> Why I get that  wrong result?

You'ld need to tell us a lot more detail about your system before anyone can
answer that.  We can guess -- the sym-link problems I talk about above are my
attempt -- and I can tell you that the command as stated works for me, where
everything is installed in a single UFS2 filesystem and it's all arranged in the
natural directory tree without trying to rearrange chunks of filesystems using
sym-links.  If you're doing anything different to that, then please say so.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20091228/83e168d5/signature.pgp


More information about the freebsd-questions mailing list