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

Fri Sep 8 20:44:46 UTC 2006
Les Mikesell <lesmikesell at gmail.com>

On Fri, 2006-09-08 at 12:38 -0400, Robert Moskowitz 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 
> >> "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'  ?

I've always thought it was a lot more straightforward to make separate
archives of each filesystem you want by cd'ing to the mount point
and  doing a 'tar --one-file-system -cvf /some/path/filesystem.tar .
than to do it in one run trying to exclude any possible mount points
you don't want.

  Les Mikesell
   lesmikesell at gmail.com