file patterns and tar

CyberLeo Kitsana cyberleo at cyberleo.net
Thu Aug 30 08:49:06 PDT 2007


Jim Stapleton wrote:
> I want to create a backup of some parts of my system, but not everything
> 
> ex, I want to exclude /bin, and /usr/bin, but not /usr/local/bin -
> same for *sbin, *lib, and *libexec
> 
> however, if I used
> 
> tar -jcvf test.tbz  \
>       --exclude /bin --exclude /usr/bin \
>       --exclude /dev --exclude /var --exclude /tmp \
>       --exclude /root --exclude /proc / | \
> tar -tf - | grep bin
> 
> I don't get /usr/local/bin files.
> 
> I coudln't find more help in tar, either through tar --help or man
> tar, though I know it says that it is excluding leading slashes in
> file names (which is probably causing this issue). What should I do,
> short of running tars for /, /usr/ and /usr/local, or is that the only
> real option? But then there is always the possiblility of missing
> something because its name just happens to contain bin, or more likely
> contains lib.

If you're going for really wacky patterns, and don't mind wrestling with
find(1), you could always pipe the output of find into tar:

find Pictures -type f -name '*.jpg' -print0 | tar cvTf - jpegs.tar --null

-- 
Fuzzy love,
-CyberLeo
Technical Administrator
CyberLeo.Net Webhosting
http://www.CyberLeo.Net
<CyberLeo at CyberLeo.Net>

Furry Peace! - http://wwww.fur.com/peace/


More information about the freebsd-questions mailing list