Working - Re: [CentOS] Taring up the OS - how to exclude directories

Fri Sep 8 18:28:16 UTC 2006
Robert Moskowitz <rgm at htt-consult.com>

Robert wrote:
> Robert Moskowitz wrote:
>> Robert wrote:
>>> Robert Moskowitz wrote:
>>>> From the howto:  http://www.faqs.org/docs/securing/chap29sec305.html
>>>>
>>>> I got some ideas to help me to tar up the OS.  I had already been 
>>>> shown how to wrap it into SSH to deposit the tar file on another 
>>>> system, so I tried the following:
>>>>
>>>> tar cpvzf - -C / --exclude  home --exclude  media --exclude  mnt 
>>>> --exclude  proc --exclude  */lost+found | ssh root at 10.0.0.2 
>>>> "cat>backup-060907.tgz"
>>>>
>>>> But, whereas the howto is talking about --exclude dealing with 
>>>> files, the Centos Man on tar is saying that it applies to files.
>>>>
>>>>
>>>> So what is wrong?  I know the SSH stuff is correct as when I put in 
>>>> something like ls I get a file with result of the ls.  Also I had 
>>>> done this without the excludes and of course it died slowing when 
>>>> it got to /media/cdrom   :(
>>>
>>> I recall that before USB2, when tape backup made sense, I used an 
>>> "exclude file" rather than doing it on the command line.  I also 
>>> remember that "/"s most definitely affect the outcome. I believe 
>>> that if you'll look at the info pages (not man) for tar, you'll find 
>>> a few examples buried in the document that will make the tar part of 
>>> your puzzle crystal clear.
>>>
>> At the very end of info tar, it talks a LITTLE bit about -- exclude 
>> PATTERN.
>>
>> I guess you have to know what pattern means.  So should I be using 
>> entries like:
>>
>> --exclude '/home'  ?
> O.K., I mounted my USB drive, went back in my archived stuff and found 
> this "exclude" file:
> -----------------------------
> [root at mavis ~]# cat /media/OT*/extra/FC1*/home/rj/nobackup
> /mnt
> /dev
> /proc
> /home/rj/mnt
> /media
> [root at mavis ~]#
> ------------------------
> You can use this rather than several --exclude entries on the command 
> by using the option -X <exclude-file-name>.
> Whatever suits you just tickles me plumb to death.
Thanks.  I could not find any clear reference to the entries in the 
--exclude-from file.  And I figured out that the reason I was getting an 
empty archive was that -C option.  I was telling tar to switch to 
directory / but not telling it what to tar!  Actually, in this case, 
there was no reason for the -C.  Taking it out got things working.  One 
question I have is that every so often the -v is showing things like the 
following:


tar: Removing leading '/' from member names
/
/sbin
/sbin/dump_cis
/sbin/request-key
/sbin/agetty

Well those were the first ones, and the reason I could catch those is at 
that point SSH prompted my for the remote user password.

If I watch the screen (without getting sick with the fast scrolling), I 
see other '/' being removed comments.