[comp.unix.i386] Backup utilities for ix-386

daves@softest.UUCP (Dave Schneider) (10/12/89)

Does anyone know of a better utility for backup (onto tape) than
"backup" and "restore". I'm looking for something along the lines
of "dump".

lisbon@vpnet.UUCP (Gerry Swetsky) (10/13/89)

> Does anyone know of a better utility for backup (onto tape) than
> "backup" and "restore". I'm looking for something along the lines
> of "dump".

    Does "backup" even work?  I got a syntax error at line 258,
    "done unexpected".

    How about:     find . -print | afio -ovzc 150 /dev/-----

--
=============================================================================
| Help stamp out stupid .signature files!		    Gerry Swetsky   |
|                                                                           |
| Home (312)833-8122  Vpnet (312)833-8126               lisbon@vpnet.uucp   |
=============================================================================

ambar@ora.UUCP (Jean Marie Diaz) (10/13/89)

I strongly recommend the Free Software Foundation's GNU tar.  It has
extentions to make it useful for full and incremental dumps.  All I
had to do to get it running on my ISC 2.0.2 machine was tweak a few
configuration options and compile.  You can find the latest version of
GNU tar on uunet and osu-cis, or your favorite friendly local archive
site.
				AMBAR
ambar@ora.com						uunet!ora!ambar

rfpfeifle@watcgl.waterloo.edu (Ron Pfeifle) (10/17/89)

In article <[253554b6:333.1]comp.unix.i386;1@vpnet.UUCP> lisbon@vpnet.UUCP (Gerry Swetsky) writes:
>> Does anyone know of a better utility for backup (onto tape) than
>> "backup" and "restore". I'm looking for something along the lines
>> of "dump".
>
>    Does "backup" even work?  I got a syntax error at line 258,
>    "done unexpected".
I got the same error, and although I don't claim to know if this really
helped, I found that line 258 (done) isn't paired with any begin loop.
I commented that line out, and it seems to work now.

Warning:  I'm not advocating this change--I'm just saying that it seemed
to fix the problem for ME. (BTW this is /usr/bin/backup, not the one
in the sysadm menu tree)

Ron

root@mustang.dell.com (0000-Admin(0000)) (10/18/89)

Commenting out the offending line is the correct fix.  This bug exists
all the way back to AT&T sources.  It is due to the routine being
declared at the top of the shell script, but all of the functionalized
code was not removed properly.  I imagine it was never found because it
is used so rarely, it never came up in testing.

mark@gizzmo.UUCP (mark hilliard) (10/19/89)

In article <11954@watcgl.waterloo.edu> rfpfeifle@watcgl.waterloo.edu (Ron Pfeifle) writes:
>In article <[253554b6:333.1]comp.unix.i386;1@vpnet.UUCP> lisbon@vpnet.UUCP (Gerry Swetsky) writes:
>>> Does anyone know of a better utility for backup (onto tape) than
>>> "backup" and "restore". I'm looking for something along the lines
>>> of "dump".

I personally like to use find piped to cpio and out to tape like:

find /partition -print | cpio -ocduBvm > /dev/tape&

Mark Hilliard
N2HHR
rutgers!rochester!kodak!gizzmo!mark

keithe@tekgvs.LABS.TEK.COM (Keith Ericson) (10/19/89)

In article <107@gizzmo.UUCP> mark@gizzmo.UUCP (mark hilliard) writes:
>
>I personally like to use find piped to cpio and out to tape like:
>
>find /partition -print | cpio -ocduBvm > /dev/tape&


A couple of minor improvements (OK - you be the judge :-))

	find /partition -print | cpio -ocduBvm > /dev/tape&
                                         ^^  ^

First of all, the -o option doesn't accept the indicated flags.  (Big
deal - cpio would've told you the same thing...)


Second, avoid the "reached end of medium on output...." message (and
careful typing required to specify the subsequent output location)
by using the -O flag:

	find /partition -print | cpio -ocBv -O /dev/tape &

(The -I flag is used for cpio -i...)


Finally, speed things up a bit with an output buffer:

	find /partition -print | cpio -ocBv -C 1024000 -O /dev/tape &

this requires that "tape" be (linked to) the character-special device
(i.e., /dev/rmt/c0s0).

kEITHe

root@mustang.dell.com (jrh) (10/19/89)

The -B option to cpio on 386/ix uses 5120 byte records to the tape, where
the normal default is 512 bytes without this option.  This is really a
slow backup, because the tape constantly seeks back and forth.  Using the
-Cbufsize option can speed up the backup process considerably.  I usually 
use something like the following:

find / -print | cpio -oacmudC128000 > /dev/tape &

This will use 128k byte records (approx.) and decrease overall backup time
by half or more depending upon the amount of data.  Of course, if you run
your backups via cron at 3AM, it won't really matter will it?  ;-)



James R. Howard
Dell Computer Corporation  P#: (512) 343-3480
9505 Arboretum Blvd.	   !s: cs.utexas.edu!dell!mustang!jrh	
Austin, Texas 78759

dave@pmafire.UUCP (Dave Remien) (10/19/89)

In article <3741@dell.dell.com+ root@mustang.dell.com (jrh) writes:
+Using the
+-Cbufsize option can speed up the backup process considerably.  I usually 
+use something like the following:
+
+find / -print | cpio -oacmudC128000 > /dev/tape &
+
+This will use 128k byte records (approx.) and decrease overall backup time
+by half or more depending upon the amount of data.  Of course, if you run
+your backups via cron at 3AM, it won't really matter will it?  ;-)

Depends on whether your version of UNIX has the cpio bug.  Some machines
would take the above cpio command and use a 1,280,000 byte buffer.  Also,
the more your tape streams, the less start/stop/reverse/stop/start it
does, and it gets to live longer.  I've never had a motor go out, but
some vendors (HP) recommend that you keep it streaming as much as
possible.  Since the HP streamer costs over $3k, I've take their advice 8-).

-- 
Dave Remien - WINCO Computer Eng. Group -{uunet | bigtex}!pmafire!dave- 
I certainly, absolutely, positively, don't speak for Westinghouse. And I
don't think I want to.			"Dave Barry for President"          

nvk@ddsw1.MCS.COM (Norman Kohn) (10/19/89)

In article <107@gizzmo.UUCP> mark@gizzmo.UUCP (mark hilliard) writes:
>I personally like to use find piped to cpio and out to tape like:
>
>find /partition -print | cpio -ocduBvm > /dev/tape&

I use a similar scheme, in a complicated shell script designed to
prevent me from messing anything up.  I'm using Bell Tech tape
with a device "/dev/tpnr" that writes but does not rewind
at the end, so that a second volume can be written.

I back up each file system individually (otherwise, the
tape may overflow and restore is difficult because the tapes
have too much data to scan efficiently).  Make file names
relative, so you can restore elsewhere in the tree (without
using chroot).  I write a short label volume in front of each
backup volume.  stream (from bell tech) or strm (if it's still
in Unix V) will immensely speed up tape speed. uport had a
bug fix requiring a specific tuning parameter for strm to work,
but I can't comment since I use bell's stream.

Finally: make sure that your script scans the tape (cpio -ivt)
for integrity lest you get a very rude surprise.

Oh, yes. DO NOT try to do your restores interactively. USE A SHELL
SCRIPT, lest you inadvertently, in your zeal to recover your precious
files, accidentally write instead of reading the tape.  (After all,
you're more used to writing it, aren't you?

-- 
Norman Kohn   		| ...ddsw1!nvk
Chicago, Il.		| days/ans svc: (312) 650-6840
			| eves: (312) 373-0564

karl@ddsw1.MCS.COM (Karl Denninger) (10/19/89)

In article <1989Oct19.031746.25893@ddsw1.MCS.COM> nvk@ddsw1.MCS.COM (Norman Kohn) writes:

....

>Oh, yes. DO NOT try to do your restores interactively. USE A SHELL
>SCRIPT, lest you inadvertently, in your zeal to recover your precious
>files, accidentally write instead of reading the tape.  (After all,
>you're more used to writing it, aren't you?

That's what the little twisty thing is for on the tapes.

I >NEVER< put a tape back in the box with that set to "writable".  Always on
"SAFE".  Then you have to think before you scribble on the tape, and if you
intend to restore you can't write over your saveset.

--
Karl Denninger (karl@ddsw1.MCS.COM, <well-connected>!ddsw1!karl)
Public Access Data Line: [+1 312 566-8911], Voice: [+1 312 566-8910]
Macro Computer Solutions, Inc.		"Quality Solutions at a Fair Price"

steve@nuchat.UUCP (Steve Nuchia) (10/19/89)

Anyone interested in fast backup for sysV should get a copy of afio
from your friendly archive.  Use an "appropriate" combination of -b
and -c with the -f option.  Afio's -f (only works with -o) does
double buffering and manages to keep both the disk and the tape busy
much of the time, as long as both buffers fit in memory.

afio also deals with corrupted archives intelligently and has
other nifty features.  It fails to be plug compatible with cpio
as far as the command line syntax goes, so read the man page and adapt.

Below is a shar of the backup script I'm in the process of developing.
It has reached the stage where it is running at several client sites
and is actually keeping stuff backed up.  If you improve it I'd
like to hear about it, but "use at your own risk", and don't pay
too much attention to the documentation...

-- 
Steve Nuchia	      South Coast Computing Services
uunet!nuchat!steve    POB 270249  Houston, Texas  77277
(713) 964 2462	      Consultation & Systems, Support for PD Software.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  all_kill bkscan design fileinfo.c fit.awk killcrunch.c
#   mcheck minit mrecycle script
# Wrapped by steve@nuchat on Thu Oct 19 09:08:45 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f all_kill -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"all_kill\"
else
echo shar: Extracting \"all_kill\" \(174 characters\)
sed "s/^X//" >all_kill <<'END_OF_all_kill'
X/\/core$/d
X/^\/tmp\/.*$/d
X/^\/usr\/tmp\/.*$/d
X/^\/files\/news\/.*\//d
X/^\/usr\/backup\/files$/d
X/^\/usr\/backup\/saved$/d
X/^\/usr\/backup\/tlist$/d
X/^\/usr\/backup\/wlist$/d
END_OF_all_kill
if test 174 -ne `wc -c <all_kill`; then
    echo shar: \"all_kill\" unpacked with wrong size!
fi
chmod +x all_kill
# end of overwriting check
fi
if test -f bkscan -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"bkscan\"
else
echo shar: Extracting \"bkscan\" \(235 characters\)
sed "s/^X//" >bkscan <<'END_OF_bkscan'
XPATH=/u/steve/bkup:$PATH; export PATH
Xif [ $# = 0 ]
Xthen
X	set `pwd`
Xfi
Xfor x
Xdo
X	d=`cd $x; pwd`
X	find $d -name '.nobackup' -print | bk_buildkill > bk_sed$$
X	find $d -print | sed -f bk_sed$$
Xdone | bk_fileprops > bk_delta$$
Xrm bk_sed$$
END_OF_bkscan
if test 235 -ne `wc -c <bkscan`; then
    echo shar: \"bkscan\" unpacked with wrong size!
fi
chmod +x bkscan
# end of overwriting check
fi
if test -f design -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"design\"
else
echo shar: Extracting \"design\" \(2447 characters\)
sed "s/^X//" >design <<'END_OF_design'
XGoals:
X
X	efficiency when filesystem is reorganized
X	efficiency in face of many links
X	work well with both small and large media available
X	positive id of volumes
X	support both backup and archiving
X	provide flexible user preference facility
X	media compatible with standard utility(s)
X	database human-readable and recoverable from media set
X	able to handle files larger than medium
X	use "cycle" algorithm
X
XEntities:
X
X	Files:  keyed by: mount-point, dev/inode, ctime, & mtime
X		contains: size, usr/grp, mode, volume assignment(s)
X
X	Directories:
X		keep track of pathnames and deletions
X
X	Volumes:
X		keep id, type, class, name + sequence
X			type = {tape,floppy...}
X			class = {offsite bkup, regular bkup, archive...}
X			time of creation
X
X	Hint files:
X		user can specify patterns, subdirs, etc
X		to not backup per directory.
X
X	Delta files: database update files.
X
X	volume header: copy of volume database record.
X
XCommands:
X
X	bkscan -- scan a directory recursively (normally /) and
X		write a delta file reflecting current reality.
X		takes .bkup-hint files into account. apply the
X		delta to the master by default if all goes well.
X
X	bkinit -- initialize or reinitialize a medium.  If reinitializing
X		it will delete references in the file table, use this
X		when a medium is lost or damaged.
X
X	bkup -- examines the files list and copies files not yet backed up
X		to media of specified class.  For media using the cycle
X		algorithm, consider the oldest N volumes lost when determining
X		what to back up.  Verify each medium as it is brought online
X		and perform all I/O for the underlying program (cpio).  Writes
X		a delta file and if all goes well applies it to the database.
X
X	bkupdate -- apply a delta to a master database file
X
X	bkreport -- format a report at various levels of detail from
X		a master or delta file.
X
X	bkgrok -- scan a bk backup medium and produce a delta for it.
X
X	bkselect -- interactive restore (or archive) file selector.
X		writes a delta file suitable for feeding to bkup
X		or bkrestore.  Runs in batch mode to drive bkup...
X
X	bkrestore -- from a delta file describing the files to be
X		restored and optional renaming parameters schedule
X		and drive restoration from specified media class.
X
XNotes: must update master before running bkup when scratching volumes.
X       what happens when the mount arrangement changes?
X
Xscan stage should be integrated with .nobackup facility
Xto save time and prevent timing windows unpleasantries.
END_OF_design
if test 2447 -ne `wc -c <design`; then
    echo shar: \"design\" unpacked with wrong size!
fi
chmod +x design
# end of overwriting check
fi
if test -f fileinfo.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fileinfo.c\"
else
echo shar: Extracting \"fileinfo.c\" \(883 characters\)
sed "s/^X//" >fileinfo.c <<'END_OF_fileinfo.c'
X/*
X *	fileinfo -- print simplified info record for each filename
X *		on stdin or argv
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <stdio.h>
X
Xchar	fnbuf[512];
X
Xmain ( argc, argv )
X	int	argc;
X	char	*argv[];
X{
X	int	i;
X
X    if ( argc > 1 ) for ( i = 1; i < argc; i++ )
X	fmtrec(argv[i]);
X    else while ( fgets ( fnbuf, sizeof(fnbuf), stdin ) )
X    {
X	fnbuf[strlen(fnbuf)-1] = 0;
X	fmtrec(fnbuf);
X    }
X}
X
X
Xstruct	stat	st;
X
Xfmtrec(f)
X	char	*f;
X{
X	long	age;
X
X    if ( stat ( f, &st ) )
X	perror ( f );
X    else
X    {
X	age = st.st_mtime;
X	if ( st.st_ctime > age ) age = st.st_ctime;
X	switch ( st.st_mode & S_IFMT )
X	{
X	case S_IFIFO: /* fifo */
X	case S_IFCHR: /* char */
X	case S_IFBLK: /* blok */
X	case S_IFDIR: /* diry */
X	    printf ( "0 0 %ld %s\n", age, f );
X	    break;
X	case S_IFREG: /* file */
X	    printf ( "0 %ld %ld %s\n", st.st_size, age, f );
X	    break;
X	}
X    }
X}
END_OF_fileinfo.c
if test 883 -ne `wc -c <fileinfo.c`; then
    echo shar: \"fileinfo.c\" unpacked with wrong size!
fi
chmod +x fileinfo.c
# end of overwriting check
fi
if test -f fit.awk -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fit.awk\"
else
echo shar: Extracting \"fit.awk\" \(635 characters\)
sed "s/^X//" >fit.awk <<'END_OF_fit.awk'
XBEGIN { state = 1; nfile=0; bot=1 }
Xstate == 3 {
X	print
X	exit
X}
Xstate == 2 {
X	size = int($3 / 512) + 3
X	if ( size > maxcap )
X	{
X		print $5 ": too big for any volume" > "assign.errors"
X		next
X	}
X	for ( i = bot; i <= nfile; i++ )
X	{
X	    if ( size <= cap[i] )
X	    {
X		cap[i] -= size;
X		break;
X	    }
X	    if ( cap[i] < 3 && i == bot && ++bot > nfile ) state = 3;
X	}
X	fname = "flist." 
X	if ( i > nfile ) print
X	else print volno[i], $3, $4, $5 > vol[i]
X}
Xstate == 1 && NF == 3 {
X	nfile++;
X	cap[nfile] = $2
X	volno[nfile] = $1
X	vol[nfile] = "flist." $1
X	if ( $2 > maxcap ) maxcap = $2
X	next
X}
X$0 == "end-of-media-list" {
X	state = 2
X	next
X}
END_OF_fit.awk
if test 635 -ne `wc -c <fit.awk`; then
    echo shar: \"fit.awk\" unpacked with wrong size!
fi
chmod +x fit.awk
# end of overwriting check
fi
if test -f killcrunch.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"killcrunch.c\"
else
echo shar: Extracting \"killcrunch.c\" \(1207 characters\)
sed "s/^X//" >killcrunch.c <<'END_OF_killcrunch.c'
X/*
X *	read .nobackup files names from stdin or argv and
X *	emit sed commands to be applied to find -print output
X *	implementing the requests found in those files.
X */
X
X#include <stdio.h>
X#include <string.h>
X
Xchar	fnbuf[512];
X
Xmain ( argc, argv )
X	int	argc;
X	char	*argv[];
X{
X	int	i;
X
X    if ( argc > 1 ) for ( i = 1; i < argc; i++ )
X	fmtkill(argv[i]);
X    else while ( fgets ( fnbuf, sizeof(fnbuf), stdin ) )
X    {
X	fnbuf[strlen(fnbuf)-1] = 0;
X	fmtkill(fnbuf);
X    }
X}
X
Xchar	rebuf[512];
X
Xfmtkill(fn)
X	char	*fn;
X{
X	FILE	*kf;
X	char	*p;
X    
X    if ( ! (kf = fopen ( fn, "r" )) ) return perror(fn);
X    if ( p = strrchr(fn,'/') ) *p = 0;
X    else fn = ".";
X    while ( fgets ( rebuf, sizeof(rebuf), kf ) )
X    {
X	rebuf[strlen(rebuf)-1] = 0;
X	fputs ( "/^", stdout );
X	re_fmt(fn);
X	fputs ( "\\/", stdout );
X	if ( rebuf[0] == '/' ) /* regexp */
X	    fputs ( rebuf+1, stdout );
X	else
X	    re_fmt(rebuf);
X	fputs ( "$/d\n", stdout );
X    }
X    fclose(kf);
X}
X
Xre_fmt(s)
X	char	*s;
X{
X    while ( *s )
X    {
X	switch ( *s )
X	{
X	case '\\':
X	case '.':
X	case '/':
X		putc('\\',stdout);
X		break;
X	case '*':
X		fputs("[^/]",stdout);
X		break;
X	case '?': 
X		fputs("[^/]",stdout);
X		s++;
X		continue;
X	}
X	putc(*s++,stdout);
X    }
X}
END_OF_killcrunch.c
if test 1207 -ne `wc -c <killcrunch.c`; then
    echo shar: \"killcrunch.c\" unpacked with wrong size!
fi
chmod +x killcrunch.c
# end of overwriting check
fi
if test -f mcheck -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"mcheck\"
else
echo shar: Extracting \"mcheck\" \(254 characters\)
sed "s/^X//" >mcheck <<'END_OF_mcheck'
Xvol=$1
Xwhile true
Xdo
X	echo load volume  $vol  and press return\\c
X	line > /dev/null
X	dd if=/dev/rmt0 bs=512 count=1 of=tmp_header 2>/dev/null
X	vid=`head -1 tmp_header`
X	if [ $vid != $vol ]
X	then
X		echo "hey, that's volume " $vid
X	else
X		exit 0;
X	fi
Xdone
END_OF_mcheck
if test 254 -ne `wc -c <mcheck`; then
    echo shar: \"mcheck\" unpacked with wrong size!
fi
chmod +x mcheck
# end of overwriting check
fi
if test -f minit -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"minit\"
else
echo shar: Extracting \"minit\" \(320 characters\)
sed "s/^X//" >minit <<'END_OF_minit'
X#
X# initialize a backup volume
X#
Xwhile true
Xdo
X    vnum=`awk '$1 > top { top = $1 } END { print top + 1 }' media.db`
X    echo "insert volume " $vnum " and press return"
X    line > /dev/null
X    mt ret
X    echo $vnum > tmp_label
X    dd if=tmp_label count=1 conv=sync of=/dev/rmt0
X    echo $vnum 110000 0 >> media.db
Xdone
END_OF_minit
if test 320 -ne `wc -c <minit`; then
    echo shar: \"minit\" unpacked with wrong size!
fi
chmod +x minit
# end of overwriting check
fi
if test -f mrecycle -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"mrecycle\"
else
echo shar: Extracting \"mrecycle\" \(78 characters\)
sed "s/^X//" >mrecycle <<'END_OF_mrecycle'
Xfor x
Xdo
X	echo "recycling volume " $x
X	ed - saved <<foo
Xg/^$x /d
Xw
Xq
Xfoo
Xdone
END_OF_mrecycle
if test 78 -ne `wc -c <mrecycle`; then
    echo shar: \"mrecycle\" unpacked with wrong size!
fi
chmod +x mrecycle
# end of overwriting check
fi
if test -f script -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"script\"
else
echo shar: Extracting \"script\" \(3473 characters\)
sed "s/^X//" >script <<'END_OF_script'
X# backup script
XPATH=/usr/backup:/usr/lbin:$PATH; export PATH
Xcd /usr/backup
X
Xcompress < files > files.Z
Xcompress < saved > saved.Z
X
X# N is number of media to use per run, max 9
XN=1
X
X# DEV is the name of the backup device
XDEV=/dev/rmt0
X
X# select N oldest media into mlist
Xsort -n +2 +0 media.db | head -$N > mlist
X
X# remember the age A of youngest
XA=`tail -1 mlist | cut -d' ' -f3`
X
X# now sort them for user convenience
Xsort -n -o mlist mlist
X
X# for unattended (tape, N=1) backup get the volume mounted,
X# otherwise let the operator gather the volumes
Xif [ $N = 1 ]
Xthen
X	vol=`cut -d' ' -f1 mlist`
X	echo Will need volume $vol
X	mrecycle $vol
X	mcheck $vol
Xelse
X	echo Will need volumes `cut -d' ' -f1 mlist`
X	mrecycle `cut -d' ' -f1 mlist`
Xfi
X
X# now scan the disk
Xecho Scanning the disk.
Xfind / -print | sed -f all_kill | fileinfo > files
X
Xecho Assigning files to media.
X
X# format of files and saved is {vol, size, tstamp, name}.  vol is
X# zero in files.  format of media.db is {vol, size, btime}.  We
X
X# files and saved are of the form (vol, size, tstamp, name),
X# with vol degenerate (0) in files.  media.db is of the
X# form (vol, size, btime). We join them into
X# tlist: {vol, btime, size, tstamp, name}.
X
X# join { files U saved } X { media.db U (0,0,0) } -> tlist
Xecho 0 0 0 | sort - media.db > mdb
Xsort +0 -1 files saved | join -j 1 -o 2.1 2.3 1.2 1.3 1.4 - mdb > tlist
X
X# format of wlist (and tlist) is (vol, btime, size, tstamp, name)
X
X# for each group differing only in volume,btime we want to keep
X# the youngest btime found, but only if the file was found in
X# the scan -- in which case there will be a vol=0 record also.
X
X# so we sort tlist such that records differing only in vol,btime are
X# grouped together in ascending btime order.  the result is piped
X# into an awk script that prints the last (most recently saved)
X# line for each group having a 0 (freshly scanned) element.
X# The sentinel is provided to help flush the last group.
X
X(sort +4 +2 -4 +1n tlist ; echo sentinel ) |
Xawk '$3 != s || $4 != t || $5 != n { if (z) print v,b,s,t,n; z=0 }
X	{ if(!$1) z=1; v = $1; b = $2; s = $3; t = $4; n = $5}' > wlist
X
X# Now wlist has one record for each record in files.  We sort
X# them into ascending btime order so that the files most in need
X# of saving will be assigned first.
X
X# now sort by btime, oldest first --
X# the zeros will sort out first.
Xsort +1n -2 +4 -o wlist wlist
X
X# now assign from wlist to N flists
X# flist.x, flist.y ... where x,y... are the volumes selected.
X# flist.0 gets any we can't assign.  In the process the btime gets stripped
X# from flist.i but not from flist.0.
X
Xrm -f flist.*
Xcp /dev/null assign.errors
Xecho end-of-media-list | awk -f fit.awk mlist - wlist > flist.0
X
X# report any errors from assignment
Xcat assign.errors
X
X# remember age T of oldest file not backed up
Xif [ -s flist.0 ]
Xthen
X	T=`head -1 flist.0 | cut -d' ' -f4`
Xelse
X	T=`rawdate`
Xfi
X
X# report overlap percentage = 100(A-T)/A
Xnow=`rawdate`
Xecho "Overlap =" `expr 100 \* \( $T - $now \) / \( $A - $now \)`"%"
X
X# for each flist.i (i != 0) copy to medium and update data bases
Xrm flist.0
Xls flist.* | cut -d. -f2 | sort -n |
Xwhile read vol
Xdo
X	if [ $N != 1 ]
X	then
X		mcheck $vol < /dev/tty
X	fi
X	dd if=$DEV count=1 of=tmp_label 2>/dev/null
X	sed -e 's/[^ ]* [^ ]* [^ ]* //' flist.$vol | sort |
X		(cat tmp_label; afio -of -b 8k -c 16 -) > $DEV
X	cat flist.$vol >> saved
X	rm flist.$vol
X	ed - media.db <<foobar
X/^$vol /s/[0-9]*\$/$now/
Xw
Xq
Xfoobar
X
Xdone
X
Xecho Backup complete.
END_OF_script
if test 3473 -ne `wc -c <script`; then
    echo shar: \"script\" unpacked with wrong size!
fi
chmod +x script
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
-- 
Steve Nuchia	      South Coast Computing Services
uunet!nuchat!steve    POB 270249  Houston, Texas  77277
(713) 964 2462	      Consultation & Systems, Support for PD Software.

johnl@esegue.segue.boston.ma.us (John R. Levine) (10/19/89)

In article <6187@tekgvs.LABS.TEK.COM> keithe@tekgvs.LABS.TEK.COM (Keith Ericson) writes:
>Finally, speed things up a bit with an output buffer:
>
>	find /partition -print | cpio -ocBv -C 1024000 -O /dev/tape &

In principle, this is a fine idea.  Actually, many versions of cpio including
all the ones on 386/ix have a bug that makes the buffer allocated by -C ten
times bigger than what you asked for, so in this case unless you have more
than 10 meg of RAM peculiar things will happen.

There is a program called "ddd" that has been kicking around the net, which
is a stripped down double buffered version of dd.  The driver for my Archive
tape drive internally allocates a 128K buffer, so my backup is roughly this,
to use two 128K buffers in ddd and another in the driver.

	find /partition -print | cpio -ocv | ddd bs=128k of=/dev/tape

There are two other things I've tried.  One is to put "compress"
between cpio and ddd.  This puts twice as much stuff on the tape, but has the
disadvantage of being much slower and if you get any error on the tape, you
can kiss everything after that point goodbye.  The other is to be more clever
about the find command -- rather than a simple find I do a:

for fn in `ls -a`
do
	case "$fn" in
		. | .. | lost+found | tmp | backuptime)
			;;	# skip
		u | usr)
			;;	# handle separately
		*)
			find $fn ! -name core ! -name "*~" -print
			;;
	esac
done | cpio -ocv | ddd bs=128K of=/dev/tape

so I can special case directories like /tmp which I don't back up, and /usr
which I want to back up last because it's a separate partition.
-- 
John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 864 9650
johnl@esegue.segue.boston.ma.us, {ima|lotus|spdcc}!esegue!johnl
Massachusetts has over 100,000 unlicensed drivers.  -The Globe

jgd@rsiatl.UUCP (John G. De Armond) (10/20/89)

The ultimate solution to backup on an IS386 system is to trash cpio completely
and use the replacement AFIO, written by Mark Brukhartz of Lachman Associates
( ..!ihnp4!laidbak!mdb ).  This program is free and is a compatable replacement
for cpio.  It does 2 things that we're particularly interested in.  First,
it has an optional double-buffering scheme whereby it forks off a daughter.
The parent reads the input and the daughter writes the output.  I've used
it on systems with a Wantek controller/drive and a Viper.  In both cases,
the tape will stream from end to end, assuming a 25 mhz system and nothing
else running.

The second thing is that it will properly handle end-of-tape.  In interactive,
the cpio "handles" end-of-tape (apparently) by keying on the special device
name given and counting bytes.  The problem arises when you use a DC-300
tape in a DC-600 drive.  Cpio merrily runs off the end of the tape.  With
afio, you specify a media size on the command line.  I've found that
59 meg is reliable for a DC-600 tape.  The command line interpreter is
intellegent enough to accept the argument "59m" instead of having to type
out "59000000".

There are a number of other improvements over standard cpio and of course,
you get the source.  And since it is free, you can't beat the price :-)

The README file lists the address I gave above for bug-fix reports and
improvements.  I'm sure they don't want to be deluged with requests for
this program.  I got my copy from an Internet site and I know it is 
on uunet.  If you exhaust all other sources, send me mail and I'll mail
you a copy.  This is currently a manual process for me so please try
other sources first.

John

-- 
John De Armond, WD4OQC                     | Manual? ... What manual ?!? 
Radiation Systems, Inc.     Atlanta, GA    | This is Unix, My son, You 
gatech!stiatl!rsiatl!jgd  **I am the NRA** | just GOTTA Know!!! 

mustard@sdrc.UUCP (Sandy Mustard) (10/21/89)

In article <1989Oct19.031746.25893@ddsw1.MCS.COM>, nvk@ddsw1.MCS.COM (Norman Kohn) writes:
> In article <107@gizzmo.UUCP> mark@gizzmo.UUCP (mark hilliard) writes:
> backup volume.  stream (from bell tech) or strm (if it's still
> in Unix V) will immensely speed up tape speed. uport had a
> bug fix requiring a specific tuning parameter for strm to work,
> but I can't comment since I use bell's stream.
> 

I currently use a uport 386 system with strm. I do not know of the
bug fix you mention.  Could you enlighten me?

Sandy Mustard
mustard@sdrc.UU.NET

misha@aeras.UUCP (Michael Umansky) (10/24/89)

-In article <329@rsiatl.UUCP> jgd@rsiatl.UUCP (John G. De Armond) writes:
-
-The second thing is that it will properly handle end-of-tape.  In interactive,
-the cpio "handles" end-of-tape (apparently) by keying on the special device
-name given and counting bytes.  The problem arises when you use a DC-300
-tape in a DC-600 drive.  Cpio merrily runs off the end of the tape.  With

Where in a world did you get the above idea?
If the tape driver is intelligent enough to parse the status from the
tape controller, it will report EOM as soon as the drive sees it.
Any normal cpio will be able to handle the EOM, especially the Sys V.3.2
version of the cpio command.
Once a cartridge tape drive sees the physical EOM marker/holes on the
tape it will not allow any requests except REWIND or WRITE_FILE_MARK.
The only way you will run it off the end of the catridge spool is by
issuing continuous WFM commands to a non-rewind device.  Only the
cartridge drive knows the difference between DC300 and DC600 type
cartridges and only for setting correct write current.
misha
-- 
NAME:	Michael Umansky (sun!aeras!foxy!misha)
WORK:	Arix Corp.;  821 Fox Lane;  San Jose, CA  95131
HOME:	4331 Lincoln Way; San Francisco, CA  94122
PHONE:	(408) 922-1751 (work); (415) 564-3921 (home)

pim@cti-software.nl (Pim Zandbergen) (10/24/89)

jgd@rsiatl.UUCP (John G. De Armond) writes:



>The second thing is that it will properly handle end-of-tape.  In interactive,
>the cpio "handles" end-of-tape (apparently) by keying on the special device
>name given and counting bytes.  The problem arises when you use a DC-300
>tape in a DC-600 drive.  Cpio merrily runs off the end of the tape.

In all Unix System V implementations I know, the device driver
fails to do the last write(2) and sets errno to ENXIO (no such
device or address). cpio catches this error and will ask for the
next medium. afio won't, but it was quite easy to fix afio to
recognize ENXIO. This way, you can use afio with any raw device,
without having to know its capacity.

Here's the patch.

*** afio.c.old	Tue Jul  5 21:25:06 1988
--- afio.c	Thu Aug 25 15:03:51 1988
***************
*** 2164,2172 ****
  				    ? syserr()
  				    : "Apparently full");
  				_exit(1);
! 			} else if (got < 0)
! 				fatal(arspec, syserr());
! 			else
  				next(O_WRONLY, "Apparently full");
  		}
  	}
--- 2164,2175 ----
  				    ? syserr()
  				    : "Apparently full");
  				_exit(1);
! 			} else if (got < 0) {
! 				if (errno = ENXIO)
! 					next(O_WRONLY, "End of medium");
! 				else
! 					fatal(arspec, syserr());
! 			} else
  				next(O_WRONLY, "Apparently full");
  		}
  	}
-- 
Pim Zandbergen                                 internet : pim@cti-software.nl
CTI Software BV                                uucp     : ..!uunet!ctisbv!pim
Laan Copes van Cattenburch 70                  phone    : +31 70 542302
2585 GD The Hague, The Netherlands             fax      : +31 70 512837

lee@sq.sq.com (Liam R. E. Quin) (10/27/89)

In article <1605@ctisbv.cti-software.nl> (Pim Zandbergen) posts a patch to
afio to handle end-of-tape.
But I spot an error in the patch:
>
>[...] it was quite easy to fix afio to
>recognize ENXIO. This way, you can use afio with any raw device,
>without having to know its capacity.
>
>--- 2164,2175 ----
>  				    ? syserr()
>  				    : "Apparently full");
>  				_exit(1);
>! 			} else if (got < 0) {
>! 				if (errno = ENXIO)
					  ^^^
This should be ==, not =.  The sysmptom is that you will never get the
error message, even when errno is not ENXIO.  It might be worth
setting errno to zero afterwards, too, if case there is a non-system error
afterwards and afio checks errno to see whether to call perror().

Hence we get
 				if (errno == ENXIO) {
					errno = 0;
 					next(O_WRONLY, "End of medium");
				} else

--
Liam Russell Quin, Unixsys (UK) Ltd
lee@sq.com (until Dec 89, then lee@anduk.co.uk again).