[comp.unix.questions] Tar file on multiple tapes

jay@alliant.backbone.uoknor.edu (Jay Liang) (10/07/90)

Is it possible to tar a single huge file on multiple tapes as dump
would do to handle file systems that are bigger than the tape
capacity?   I understand spliting up the file solves the problem but
it is not graceful (read: ugly).  Thanks for the pointers.

-- 
Jay Liang                |   University of Oklahoma   |   (405) 325-5540
jay@alliant.uoknor.edu   |   jay@uokmax.uoknor.edu    |   chinet!uokmax!jay

avg@hq.demos.su (Vadim G. Antonov) (10/07/90)

In article <1990Oct6.235203.24093@uokmax.ecn.uoknor.edu> jay@alliant.backbone.uoknor.edu (Jay Liang) writes:
>Is it possible to tar a single huge file on multiple tapes as dump
>would do to handle file systems that are bigger than the tape
>capacity?


If your local tar does not support multi-tape feature (RTFM),
you could write something like (Bourne shell):

tar cf - your_files | while true
do echo -n "Mount the (next) tape (type CR of ^C to quit):"
   gets < /dev/tty
   dd of=/dev/TAPE bs=20b count=SIZE
done

where TAPE is the name of RAW tape device and SIZE is the
size of tape in 10K records.

If you have no (very useful) gets, the source follows:

main()
{
	char c;

	while( read(0, &c, 1) != 1 ) {
		write(1, &c, 1);
		if( c == '\n' )
			exit(0);
	}
	exit(1);
}

(Hmmm... try to guess why I use read/write instead of getc/putc :-).

	Vadim Antonov
	DEMOS, Moscow, USSR

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/08/90)

In article <1990Oct7.160605.13851@hq.demos.su> avg@hq.demos.su (Vadim G. Antonov) writes:
>(Hmmm... try to guess why I use read/write instead of getc/putc :-).

Because you have a broken tty handler?
Because you like inefficient code?
?

cbp@icc.com (Chris Preston) (10/09/90)

In article <1990Oct7.160605.13851@hq.demos.su> avg@hq.demos.su (Vadim G. Antonov) writes:
>In article <1990Oct6.235203.24093@uokmax.ecn.uoknor.edu> jay@alliant.backbone.uoknor.edu (Jay Liang) writes:
>>Is it possible to tar a single huge file on multiple tapes as dump
>>would do to handle file systems that are bigger than the tape
>>capacity?
>
>
>If your local tar does not support multi-tape feature (RTFM),
>you could write something like (Bourne shell):
>
>tar cf - your_files | while true
>do echo -n "Mount the (next) tape (type CR of ^C to quit):"
>   gets < /dev/tty
>   dd of=/dev/TAPE bs=20b count=SIZE
>done
>
>where TAPE is the name of RAW tape device and SIZE is the
>size of tape in 10K records.
>
>If you have no (very useful) gets, the source follows:
[deleted]

 A solution that uses `read' and `while' follows:

	tar cvf - /usr 2>filelist |
	while [ -z "$ans" ] && dd of=/dev/rmt0 bs=$BUFSIZ count=$BCOUNT 
	do
	  echo "\n\n\n\ttype carriage return to continue"
	  echo "\tor any non white-space character"
	  echo "\tand return to quit -> \c"

	  read ans < /dev/tty   #my personal version of gets 
                            #it's in the fine manual even :-) 

	  echo "\n\n\n"
	done
	  # remember we quit on the first dd that is not a complete
	  # record - 0+3 or somesuch, or do one iteration of 0+0 for sure


which would seem more standard and works in sh and csh.  (assuming
one defines BUFSIZ and BCOUNT).

One might also do this in 2400/2800? (I forget just now) block increments in
order to produce high density floppy (5 1/4":3 1/2") diskettes and add a
little `expr' to number them (for those of us without tape
drives at home for backups ... yet).  If one wanted the file list to
be seen as well (smaller now, we hope), one could do:

	$dno=0
	tfile="/tmp/foo$$"
	tar cvf - /usr |          #put favorite compression in pipe here
	while [ -z "$ans" ] && 
		dno=`expr $dno+1` && 
		(dd of="/tmp/disk$dno" bs=$BUFSIZ count=$BCOUNT 2>$tfile) 
	do

	  cat $tfile   # insures that the output from dd 
	  echo "ditto prompt from above\c"

	  read ans < /dev/tty
	  echo "\n\n\n"

	done
	rm $tfile

dd is in a subshell in the second case for csh user benefit 
(disclaimer - which I am not).

One can substitute a device in the second case as well and do
away with the `expr' bit, and the test could be more explicit
with regards to input (say -eq "y").


cbp
---
"When Saddam Hussein stops by a Quality, Clarion, or Comfort Inn, ...
ee' don' need no stinkin' discount card."

cbp@icc.com (Chris Preston) (10/09/90)

In article <1990Oct9.042831.20159@icc.com> cbp@icc.com (Chris Preston) writes:
>In article <1990Oct7.160605.13851@hq.demos.su> avg@hq.demos.su (Vadim G. Antonov) writes:
>>In article <1990Oct6.235203.24093@uokmax.ecn.uoknor.edu> jay@alliant.backbone.uoknor.edu (Jay Liang) writes:
>>>Is it possible to tar a single huge file on multiple tapes as dump
>>>would do to handle file systems that are bigger than the tape
>>>capacity?
>
> A solution that uses `read' and `while' follows:
>

[deleted]

  A single addition:

  BSD and Pre-SysV shells notwithstanding.

cbp
---
"When Saddam Hussein stops by a Quality, Clarion, or Comfort Inn, ...
ee' don' need no stinkin' discount card."

avg@hq.demos.su (Vadim G. Antonov) (10/11/90)

In article <1990Oct9.042831.20159@icc.com> cbp@icc.com (Chris Preston) writes:
>	  read ans < /dev/tty   #my personal version of gets 
>                            #it's in the fine manual even :-) 

	Unfortunately I've seen shells where it does not work :-(
	(How many BD things are floating around!)

	Vadim Antonov
	DEMOS, Moscow, USSR
	(It is a joke!)

cbp@icc.com (Chris Preston) (10/14/90)

In article <1990Oct10.181018.10634@hq.demos.su> avg@hq.demos.su (Vadim G. Antonov) writes:
>In article <1990Oct9.042831.20159@icc.com> cbp@icc.com (Chris Preston) writes:
>>	  read ans < /dev/tty   #my personal version of gets 
>>                            #it's in the fine manual even :-) 
>
>	Unfortunately I've seen shells where it does not work :-(
>	(How many BD things are floating around!)
>
>	Vadim Antonov
>	DEMOS, Moscow, USSR
>	(It is a joke!)

Yes, I did a follow-up that this is not necessarily so outside of
SysV shell.  

Just check with your local GRU chief and see if they can't give
you something a little more up to date, eh?  (Hmmmmm, 1/2 :-) 


cbp
---
Kurt Waldheim to Saddam Hussein -
"Saddam, I knew Hitler, and believe me, you're no Adolf Hitler"