Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jul 2005 13:42:30 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Drew Tomlinson <drew@mykitchentable.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: tar Syntax Help
Message-ID:  <20050708104230.GB22902@beatrix.daedalusnetworks.priv>
In-Reply-To: <42CDF112.5070209@mykitchentable.net>
References:  <42CDF112.5070209@mykitchentable.net>

index | next in thread | previous in thread | raw e-mail

On 2005-07-07 20:20, Drew Tomlinson <drew@mykitchentable.net> wrote:
> I'm trying to copy an entire file system while using an exclude file
> to avoid copying things such as /dev, /proc, etc.  I've read the man
> page and found the -X or --exclude-from tar option.  I've create a
> file called /exclude.list.  It contains lines such as:
>
> /exclude.list
> /dev
> /proc
>
> But I can't figure out how to form the correct command line.  I
> basically want to do this:
>
> tar -cvf - --exclude-from /exclude.list -C / . | tar xpf - -C .

Perhaps not what you're looking for, but you can perform a similar
"exclude" operation on the output of find(1), using one or more grep(1)
patterns and then feed the rest to cpio(1) in 'pass-through' mode:

	# cd /
	# find / | \
	    grep -v '^/dev/.*' | grep -v '^/proc/.*' | \
	    grep -v '^/mnt/.*' | \
	    cpio -p -dmvu /mnt

The most important detail above is that the childen of /dev, /proc and
/mnt are excluded, but not the directories themselves.  This is why I
trim from the output of find '^/dev/.*' but not '^/dev', '^/proc/.*' but
not '^/proc', etc.

- Giorgos



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050708104230.GB22902>