[WBEL-users] Disc cloning

Kirby C. Bohling kbohling at birddog.com
Tue Mar 8 18:18:03 CST 2005


On Tue, Mar 08, 2005 at 02:51:58PM -0600, Dan wrote:
<snip long explaination of copying drives with tar>
> > If I was a good little Admin, I'd use cpio instead of tar, as 
> > this will only work with GNU tar.  Well, it won't work with 
> > original UNIX tar, because it would open of special devices, 
> > where GNU tar by default will just copy the special device 
> > file instead of copying the contents you get by running 
> > "open" on the special device.
> > However, I'm not a fluent in cpio.
> 
> cd /tmp/orig
> find . -print | cpio -pmd /tmp/dest
> 
> -dan
> 

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.  Guess I've been bitten too
many times.  Files with shell metacharacters, quotes, escapes,
newlines, control characters are fairly common for me, so everything
I shell script has to be able to deal with it.  Always prefer:

This: find ... -exec [command] {} \; 
Over: find ... -print | xargs [command]

unless you have a compelling reason (speed generally).

I guess I might have a reason why I don't use cpio, as according to
the man page there is no way to give it the files on the command
line.

If you have any concerns about file names, I'd use this version:

find . -print0 | cpio -pmd --null /tmp/dest

That should be safe (I can't imagine a file having a NULL in the
file name as being legal, although, I wouldn't be shocked for it to
be legal if unicode is used for the file names).  That should be
save.

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.

	Kirby




More information about the Whitebox-users mailing list