How to force tar to be quiet?
Коньков Евгений
kes-kes at yandex.ru
Mon Dec 28 15:16:19 UTC 2009
Здравствуйте, Matthew.
Вы писали 28 декабря 2009 г., 12:04:47:
#cd /
# ls -l
total 5111
-rw-r--r-- 2 root wheel 786 7 сен 2008 .cshrc
-rw-r--r-- 2 root wheel 253 7 сен 2008 .profile
drwxrwxr-x 2 root operator 512 8 окт 2008 .snap
-r--r--r-- 1 root wheel 6188 7 сен 2008 COPYRIGHT
drwxr-xr-x 2 root wheel 1024 21 ноя 2008 bin
drwxr-xr-x 8 root wheel 512 16 июн 2009 boot
lrwxr-xr-x 1 root wheel 10 8 окт 2008 compat -> usr/compat
dr-xr-xr-x 4 root wheel 512 15 дек 18:41 dev
lrwxr-xr-x 1 root wheel 14 23 ноя 2008 e -> /usr/local/etc
-rw------- 1 root wheel 4096 9 ноя 01:02 entropy
drwxr-xr-x 21 root wheel 2560 25 дек 22:43 etc
lrwxr-xr-x 1 root wheel 8 8 окт 2008 home -> usr/home
drwxr-xr-x 3 root wheel 1536 21 ноя 2008 lib
drwxr-xr-x 2 root wheel 512 21 ноя 2008 libexec
lrwxr-xr-x 1 root wheel 36 13 янв 2009 m -> /usr/local/lib/perl5/site_perl/5.8.8
drwxr-xr-x 2 root wheel 512 7 сен 2008 media
drwxr-xr-x 2 root wheel 512 7 сен 2008 mnt
lrwxr-xr-x 1 root wheel 19 14 дек 2008 p -> /home/kes/projects/
dr-xr-xr-x 1 root wheel 0 28 дек 17:14 proc
lrwxr-xr-x 1 root wheel 19 23 ноя 2008 r -> /usr/local/etc/rc.d
-rw-r--r-- 1 root wheel 4787 15 дек 18:42 razor-agent.log
drwxr-xr-x 2 root wheel 2560 21 ноя 2008 rescue
drwxr-xr-x 7 root wheel 512 3 ноя 20:53 root
lrwxr-xr-x 1 root wheel 21 5 дек 2008 s -> /usr/local/sharedzone
drwxr-xr-x 2 root wheel 2560 21 ноя 2008 sbin
lrwxr-xr-x 1 root wheel 11 21 ноя 2008 sys -> usr/src/sys
-rw-rw-rw- 1 root wheel 1854498 28 дек 07:40 test
drwxrwxrwt 12 root wheel 520192 28 дек 15:34 tmp
drwxr-xr-x 17 root wheel 512 3 янв 2009 usr
lrwxr-xr-x 1 root wheel 18 4 дек 2008 v -> /usr/local/virtwww
drwxr-xr-x 29 root wheel 512 15 дек 18:41 var
-rw------- 1 root wheel 2727936 11 дек 10:56 verlihub.core
# uname -a
FreeBSD kes.net.ua 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Sat Jan 3 01:15:39 EET 2009 kes at kes.net.ua:/usr/obj/usr/src/sys/KES_KERN_v7 i386
# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ad1s1a 496M 267M 189M 59% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/ad1s1f 496M 116M 340M 26% /tmp
/dev/ad1s1g 38G 21G 14G 61% /usr
/dev/ad1s1e 7.7G 6.1G 1.0G 86% /var
/dev/ad1s1d 23G 8.0K 21G 0% /usr/local/squid
procfs 4.0K 4.0K 0B 100% /proc
devfs 1.0K 1.0K 0B 100% /var/named/dev
Shell I use: /bin/sh
To reproduce try next:
NOTICE i have more than two (as in your example) directories to tar
I have two of them with same begin path: usr/local
usr/local/etc usr/local/virtwww
MS> Коньков Евгений 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.
MS> Yep. As shown, you don't need '*' here. tar(1) is perfectly capable of recursing
MS> through a directory hierarchy given only the name of the top level directory.
MS> [ * is actually expanded by your shell, rather than tar, so it's trying to match
MS> filenames against your current working directory, and not against the directory
MS> 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
MS> Hmmm... I can't reproduce this locally. If I run:
MS> sudo tar -cf foo.tar -C / etc boot
MS> then I get (as expected) a tarball with the contents of /etc and /boot -- not
MS> only that, but there's nothing printed to stdout/stderr while the command runs.
MS> Are any of the directories concerned symbolic links on your system? tar(1)
MS> handles sym-links quite carefully given that it's possible to use them to
MS> generate specially crafted tar archives that you can use to trick an unwary
MS> admin into overwriting security sensitive files. As a rule of thumb, when
MS> specifying directory trees to back-up, try and avoid having any path components
MS> 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?
MS> You'ld need to tell us a lot more detail about your system before anyone can
MS> answer that. We can guess -- the sym-link problems I talk about above are my
MS> attempt -- and I can tell you that the command as stated works for me, where
MS> everything is installed in a single UFS2 filesystem and it's all arranged in the
MS> natural directory tree without trying to rearrange chunks of filesystems using
MS> sym-links. If you're doing anything different to that, then please say so.
--
С уважением,
Коньков mailto:kes-kes at yandex.ru
More information about the freebsd-questions
mailing list