[WBEL-users] Disc cloning

Kirby C. Bohling kbohling at birddog.com
Wed Mar 9 09:00:33 CST 2005


On Wed, Mar 09, 2005 at 08:57:48AM +0200, Andy Rabagliati wrote:
> On Tue, 08 Mar 2005, Kirby C. Bohling wrote:
> 
> > On Tue, Mar 08, 2005 at 02:51:58PM -0600, Dan wrote:
> > > 
> > > cd /tmp/orig
> > > find . -print | cpio -pmd /tmp/dest
> > > 
> > 
> > Hmmm, how does cpio handle things with spaces newlines or other
> > nasties in the file name (carriage returns among other things).  I
> > copy filesystems that I don't get any control over the file names,
> > so out of habit, I distrust anything that uses "find ... -print" and
> > passes that as input to another command.
> > 
> > This: find ... -exec [command] {} \; 
> > Over: find ... -print | xargs [command]
> 
> Notice there is no 'xargs' in Dan's solution.

The xargs is irrelavent, it's just a standard technique (I do use it
for files I do have complete control over the naming).  cpio could
be in there.  Anything that takes files on stdin (tar -T comes to
mind), xargs, and any other number of commands don't work with file
names I deal with on a regular basis by "default".  You have to have
special cases/flags to deal with them.  I've seen enough people get
bit by them.  It appears that cpio at least uses newlines as
opposed to whitespace by default (which is very good, it avoids a
whole slew of problems).  A lot of programs use whitespace, thinking
it won't occur in filenames.

> 
> > If you have any concerns about file names, I'd use this version:
> > 
> > find . -print0 | cpio -pmd --null /tmp/dest
> 
> But does cpio handle null-separated filenames ?

Yes, GNU cpio does if you use the --null flag.  (Hence the reason I
included it in the quoted command line).

> 
> xargs has the -0 switch - cpio would need the same.

That's true, GNU cpio does, see above.

> 
> > Thanks for the reply.  I always end up reading on cpio anytime I
> > unpack Oracle Server distributions, other then that I am just
> > blissfully ignorant.  I now understand why "pass-thru exists".  I
> > never understood it before.
> 
> I would trust cpio talking to cpio before trusting find talking to cpio.
> 

That's true, but there's no way to tell cpio, here is a directory,
archive absolutely everything underneath it.  At some point you have
to give cpio a list of filenames on stdin from my reading of the man
page.  I might have missed the option.

I'll have to crack out my O'Reilly Backup book.  That guy was one of
the people who turned me onto using reliable tar command lines.  I
believe he had a command line he used cpio in that was reliable for
moving filesystems that was simple and straightforward.  I don't
have a copy handy.

	Thanks,
		Kirby



More information about the Whitebox-users mailing list