[comp.sources.d] cpio/afio writing directories?

root@libove.UUCP (The Super User) (05/27/88)

I'm using afio (operationally very like cpio, for those who've never
seen afio; if you use cpio and don't have afio, get afio!) to back up
a SCO Xenix file system. But I doubt that the system type matters any.

Basically, it seems that cpio/afio, unlike tar, require real file names,
not just directory names... such that:

% tar cf tarfile /x /y /z

will back up the directories /x /y /z and all their files and
subdirectories, but:

% echo '/x /y /z' | afio -o archive

will simply create information about the *directories* /x /y /z on the
archive, and *not* backup the files and subdirectories in them! It becomes
necessary to use:

% echo /x/* /y/* /z/* | afio -o archive

to convince afio/cpio to do the directories and everything underneath
(afio/cpio *do* take a directory in a listed file's subdirectory as
'back this and its children up also', e.g. /x/* including /x/aa *will*
get /x/aa/* backed up, &etc...)

My question: How do I tell afio/cpio that 

% echo '/x /y /z' | afio -o

means /x /y /z and all subfiles also?

Thanks!
Jay Libove (Jay.Libove@andrew.cmu.edu  or  pitt!darth!libove!libove)
-- 
Jay Libove (Jay.Libove@andrew.cmu.edu  or  pitt!darth!libove!libove)

hoffman@pitt.UUCP (Bob Hoffman) (06/01/88)

In article <23@libove.UUCP> root@libove.UUCP (The Super User) writes:
>... it seems that cpio/afio, unlike tar, require real file names,
>not just directory names...

Right.  Tar knows how to traverse directories; afio does not.  Afio
wants a complete path to each file.  An excerpt from the afio manual page:

     With -o, reads pathnames from the standard input and writes
     an archive.

>My question: How do I tell afio/cpio that 
>
>% echo '/x /y /z' | afio -o
>
>means /x /y /z and all subfiles also?

Echo is not what you want.  Use this:

% find /x /y /z -print | afio -o

	---Bob.

-- 
Bob Hoffman, N3CVL       {allegra, bellcore, cadre, idis, psuvax1}!pitt!hoffman
Pitt Computer Science    hoffman@vax.cs.pittsburgh.edu

les@chinet.UUCP (Leslie Mikesell) (06/03/88)

In article <23@libove.UUCP> root@libove.UUCP (The Super User) writes:
>
>My question: How do I tell afio/cpio that 
>
>% echo '/x /y /z' | afio -o
>
>means /x /y /z and all subfiles also?

The usual way is to use find instead of echo:

  find dir1 dir2 dir3 -depth -print |afio -o

The -depth flag causes the directories themselves to be printed last so
the modes will restore properly and makes it possible to deal with
read-only directories.

Be sure you know what you are doing if you use (or don't use) absolute
pathnames for the starting directories.  If you start with a /, then
the restore operation will only be able to put the files back into their
original absolute positions.  If you cd to the starting point and find ".",
or one above and find "dirnname", then the files will restore relative
to your current directory.  

Has anyone hacked afio to strip an optional number of leading directories
from the path during a restore?  Something like the -pn parameter in patch
would be nice.

Les Mikesell

wnp@dcs.UUCP (Wolf N. Paul) (06/03/88)

In article <23@libove.UUCP> root@libove.UUCP (The Super User) writes:
 >I'm using afio (operationally very like cpio, for those who've never
 >seen afio; if you use cpio and don't have afio, get afio!) to back up
 >a SCO Xenix file system. But I doubt that the system type matters any.
 >
 >Basically, it seems that cpio/afio, unlike tar, require real file names,
 >not just directory names... such that:
 >
 >% tar cf tarfile /x /y /z
 >
 >will back up the directories /x /y /z and all their files and
 >subdirectories, but:
 >
 >% echo '/x /y /z' | afio -o archive
 >
 >will simply create information about the *directories* /x /y /z on the
 >archive, and *not* backup the files and subdirectories in them!
 
Correct! If you look at the man page for cpio, all of the examples use
"find" to get the list of files to back up. Thus, as a minimum this is
what your commandline should look like:

% find /x /y /z -print | afio -o archive

or the corresponding cpio example:

% find /x /y /z -print | cpio -oc archive

This is consistent with the software tools approach -- if there is a command
"find" which can list a directory hierarchy, why put the same code into the
archiver? Just connect the two with a pipe.
-- 
Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101
UUCP:     ihnp4!killer!dcs!wnp                 ESL: 62832882
DOMAIN:   wnp@dcs.UUCP                         TLX: 910-280-0585 EES PLANO UD

richardh@killer.UUCP (Richard Hargrove) (06/04/88)

In article <23@libove.UUCP>, root@libove.UUCP (The Super User) writes:
> My question: How do I tell afio/cpio that 
> 
> % echo '/x /y /z' | afio -o
> 
> means /x /y /z and all subfiles also?

The simplest way is one of either

	find /x /y /z -print | cpio -o...

or

	find /x /y /z -type f -print | cpio -o...

depending on whether you want directory information stored or not (it
will be important if you're restoring under a different uid).

The version of find(1) on uPort SYS V/AT has a -cpio option that invokes
cpio for you. I've seen references to versions supporting a -prune option 
which is used to control the depth of the descent of the tree walk.

richard hargrove
...!{ihnp4 | codas | cbosgd}!killer!richardh
--------------------------------------------

dave@galaxia.zone1.com (David H. Brierley) (06/05/88)

In article <5739@chinet.UUCP> les@chinet.UUCP (Leslie Mikesell) writes:
[ much stuff deleted discussing how to use cpio]
>Be sure you know what you are doing if you use (or don't use) absolute
>pathnames for the starting directories.  If you start with a /, then
>the restore operation will only be able to put the files back into their
>original absolute positions.  If you cd to the starting point and find ".",
>or one above and find "dirnname", then the files will restore relative
>to your current directory.  

On my 3B1, which up until now I had assumed was using the standard SV utilities,
the cpio program has an upper-case R option which is described as follows:

"Allow file and directories with absolute path names to be redirected on input
to the current directory by removing the leading / from the path name."

Does this option exist in other version of cpio and people just dont know about
it or is the 3B1 unique in this regard?
-- 
David H. Brierley
Home: dave@galaxia.zone1.com   ...!rayssd!galaxia!dave
Work: dhb@rayssd.ray.com       {sun,decuac,cbosgd,gatech,necntc,ukma}!rayssd!dhb

jv@mhres.mh.nl (Johan Vromans) (06/05/88)

From article <23@libove.UUCP>, by root@libove.UUCP (The Super User):
> 
> I'm using afio (operationally very like cpio, for those who've never
> seen afio; if you use cpio and don't have afio, get afio!) ...
                                                  ^^^^^^^^
Where & how?

> My question: How do I tell afio/cpio that 
> 
> % echo '/x /y /z' | afio -o
> 
> means /x /y /z and all subfiles also?

Use 'find' instead of echo:

 % find /x /y /x -print | afio -o

See find(1).

-- 
Johan Vromans                              | jv@mh.nl via European backbone
Multihouse N.V., Gouda, the Netherlands    | uucp: ..{uunet!}mcvax!mh.nl!jv
"It is better to light a candle than to curse the darkness"

caf@omen.UUCP (Chuck Forsberg WA7KGX) (06/06/88)

I have switched to afio for backing up files on Xenix
because the resulting archive is much smaller than with
tar, and because afio is much faster than cpio.

Both cpio and afio are meant to be driven by find:
"find caf spool/yam telegodzilla lib -print | afio -ovzb 32k /dev/rct0"

The find -newer option is useful for incremental backups.

les@chinet.UUCP (Leslie Mikesell) (06/06/88)

In article <478@galaxia.zone1.com> dave@galaxia.zone1.com (David H. Brierley) writes:
>On my 3B1,which up until now I had assumed was using the standard SV utilities,
>the cpio program has an upper-case R option which is described as follows:
>
>"Allow file and directories with absolute path names to be redirected on input
>to the current directory by removing the leading / from the path name."

The 3B1 is pretty far from having standard SV utilities as you might guess
from looking at the first 20 pages of the user's manual vol II which consist
of things that are different from normal SysV. Here's what it says about cpio:

cpio(1)  The K, R, O, J, and x options are not available in System V Release 2.

The manual for the AT&T 6386 SVr3.1 shows a few new options, but -R (or similar
functionality) is not among them.

 Les Mikesell