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

Tue Sep 12 02:14:01 UTC 2006
John Summerfield <debian at herakles.homelinux.org>

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 know this works for me:
tar clf homes.tar --exclude=scripts --exclude=conf --exclude=bin \
  --exclude=incoming -C ${BASEDIR} .



but I had a completely garbage backup of my firewall, taken just before 
the disk died (I thought, briefly, how fortuitous my timing was!) using 
ssh that way.

The problem is, I have this alias:
alias ssh='ssh -t'
and the result of that is the shell (or something) injects the 
occasional screen control sequence, and my backup was cactus. Absolute junk.

The way to be sure is:
tar cpvzf - -C / <more tar stuff> | \ssh <ssh stuff>

btw unless you have a very fast CPU and/or a slow link, it's faster 
without the compression.

You might also find it simpler to use the "l" switch as I do to avoid 
crossing filesystem boundaries; in your case it would automatically 
exclude /proc, /sys and anything mounted anywhere, such as /media, 
/home, /mnt. I do this:
tar clC / / /boot /home  /var \
| tar xpC /mnt/backup || { df -h ; exit ; }

I do have a list of exclusions (eg --exclude=/var/spool/postfix/), 
enough to cloud the issue:-)

This example's on Debian, and the buffer command's there in hopes of 
reducing head movement and so accelerating the process.


-- 

Cheers
John

-- spambait
1aaaaaaa at coco.merseine.nu  Z1aaaaaaa at coco.merseine.nu
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/

Please do not reply off-list