Exclude hidden files/folders from backup

Ken Schweigert yellowdog-general@lists.terrasoftsolutions.com
Fri Mar 26 10:18:01 2004


On Thu, Mar 25, 2004 at 10:48:51PM +0000, Dene Stringfellow wrote:
> Ken,
> 
> Thanks for your reply.
> 
> So, if I've understood correctly and I want to back up /home but exclude
> any hidden files or directories (- including any that might be in
> sub-directories), I should run something like:
> 
> tar --exclude .AppleDouble .AppleDesktop .kde .gtkrc -cvf /dev/tape
> /home
> 
> Would this be right?
> Is there any way of specifying all hidden files with something like .* ?
> 

The above command won't work because of how tar accepts it's command line
parameters.  It'll exlude .AppleDouble but when it reads .AppleDesktop it
thinks it's another parameter which it doesn't understand.

There are a couple ways of doing this.  If these are the exact dot files
you need to exclude you can just use --exclude for each file.  i.e.
	[ken@byteme ken]$ tar --exclude .AppleDouble --exclude .AppleDesktop 
		--exclude .kde --exclude.gtkrc -cvf ...

Or you could push the names of the dot files into a file and send that to
tar.  i.e.
	[ken@byteme ken]$ find ./ -name ".*" > dot-files
	[ken@byteme ken]$ tar --exclude-from dot-files -cvf test.tar /home

And if you're running your backup from cron, just make a simple shell script
that does the "find" for you and have it run a minute or two before your
backup script.

HTH
-- 
Ken Schweigert, Network Administrator
Byte Productions, LLC
http://www.byte-productions.com