tar or cpio, which is better?

Greg A. Woods woods at eci386.uucp
Thu Nov 22 04:27:17 AEST 1990


I've not paid tremendous attention to this thread up to now, but I
don't recall anyone mentioning what I'm about to.

In article <329 at metran.UUCP> jay at metran.UUCP (Jay Ts) writes:
> In article <1990Nov15.192615.1238 at hemel.bull.co.uk>, mpreen at hemel.bull.co.uk (Malcolm Preen) writes:
> > sparks at power.viewlogic.com (Alan Sparks) writes:
> > 
> > >In article <1990Nov12.095657.22489 at erbe.se> prc at erbe.se (Robert Claeson) quoted:
> > >[.... and someone else, presumably writes ....]
> > >>Using cpio instead worked just fine. Also, for backup purposes,
> > >>cpio is probably the best. It comes *standard* with the ability to
> > >>detect end-of-tape and create multi-volume archives. It has better
> > >>support for incremental backups and selective restores. And it supports
> > >>longer paths than tar's limit of 100 characters.
>[ and I deleted some words about XENIX ]
> Oh dear, all this brings a up a few more topics concerning cpio (and tar).
>[....]
> The problem is that I want the script system to run *unmodified* on any UNIX
> system, be it Xenix System V 286, 386; ISC 2.0, 2.2; ESIX or whatever.  So far,
> tar and cpio seem to work differently on each system!
>[....]
> These are clearly issues for the standards bodies.  Until then, my best advice
> is to decide for yourself which of cpio and tar work best for you and your
> system, and try to be consistent!  If another S.A. asks for something on tape,
> ask him/her which format to use, and clearly mark on any tape you write what
> the format is, maybe also providing a suggestion such as:

They [the standards bodies] are way ahead of you....  POSIX 1003.1
defines two portable archive interchange formats: extended tar, and
extended cpio.  POSIX 1003.2 Draft 9 / August 1989 defines a programme
called "pax - portable archive interchange" which supports both of
these formats.  A third new format is under development to "address
all restrictions and new requirements for security labeling, etc."

It, and its resulting archives, are portable across many UNIX based,
or POSIX compatible, systems.

It definitely supports multiple volumes.

It is extremely easy to use and very flexible.

It can do the directory tree copying tasks of either tar or cpio with
great ease as well.

It is available today as freeware source code (commissioned by the
IEEE for the 1003.2 standard).  (v2.0 was posted some time ago to
comp.sources.????)  It is quite solid, and it works.

I've had no trouble with it reading media written with older tar or
cpio programmes.  1003.2 suggests the default output format to be
implementation defined, and the available source defaults to USTAR.
The default will likely be the new format, once it is defined.

In some part of the pax source it mentions that "pax" is Latin for
"peace"....

> 	1. Lack of verification - I can do a listing of a cpio tape,
> 	   but that only checks the headers, not the files' contents.

If you can read the tape to get a directory, then the tape is OK, or
else your device driver is broken or lying.  Pax will identify
clobbered files and attempt to skip to the next good one.  If you are
using some ancient hardware (such as maybe 9-track) that can't tell
the difference between a good read, and a bad one, that's your tough
luck.  Seriously.  If your backups are important, use known good media
on a device that does lots of error checking in hardware.

> 	2. Speed - The UNIX-variants I've used are incredibly slow
> 	   writing to floppies with cpio.  I know UNIX is inherently
> 	   slower due to double-copying of buffers between kernel and
> 	   user space, but that just does not explain the difference!

Pax does nothing about double-buffering, though it will use *any*
buffer size you want.  If you have intelligent devices and/or device
drivers, then you are off to the races with a good chance of winning.
On the other hand, if you have a device which accepts maximum 8 Kb
buffers, and slowly, such as the 3b2 CTC drive, you lose.  However pax
can read tapes created with ctccpio from this device, and survive bad
blocks to boot.

> 	3. User interface - need I say more???  You know as well as I
> 	   do (I hope) what happens if you are on the 21st of a 23 floppy
> 	   cpio, you get prompted "Insert disk 22: ", and you hit Enter
> 	   *twice* by mistake.  Errrrr!!!

I think you'll find pax is far better than either tar or cpio....
As for the example problem you identify, the only good solution,
beyond flushing the input buffer before reading important things,
would be to have some form of volume header with a label on it.
-- 
						Greg A. Woods

woods@{eci386,gate,robohack,ontmoh,tmsoft}.UUCP		ECI and UniForum Canada
+1-416-443-1734 [h]  +1-416-595-5425 [w]    VE3TCP	Toronto, Ontario CANADA



More information about the Comp.unix.admin mailing list