From: krus@cs.concordia.ca (Mike Krus)
Subject: Re: I'd really like a *COMPRESSED* backup...
Organization: Computer Science, Concordia University, Montreal, Quebec
Date: Tue, 13 Oct 1992 18:49:39 GMT

In article <1992Oct12.150115.19348@cs.ucf.edu> hab@engr.ucf.edu (Hubert Bahr) writes:
>In article <2935@nlsun1.oracle.nl> jhelberg@nl.oracle.com (Joost Helberg) writes:
>>haible@ma2s2.uucp (Bruno Haible) writes:
>>: > I managed to get the multi-volume tar business to work under Linux.
>>: > To back everything up, I do:    tar -cMvpf /dev/fd0 +same-owner +totals /
>>: > I just can't seem to get the -Z option to work along with the -M option.
>>: 
>>: Try using tar twice: once for compressing, once for putting the stuff onto
>>: your disks. For example:
>>: 
>>:      tar cvfz /tmp/usr.bin.tar.Z /usr/bin
>>:      tar cvfM /dev/fd0 /tmp/usr.bin.tar.Z
>>This will work, but you need temp. space when creating the archive, but
>>when restoring it too! The last thing is not what you want!
>>
>>try:
>>
>>tar cvfz - <files> | fdio w /dev/fd0H1440
>>
>>and
>>
>>fdio r /dev/fd0H1440 | tar xvfz - <files> 
>>

I have this shell script which does direct compression of tar. I'm sure it's
works on Linux 'cause I don't have it. As stated in the header it doesn't work
on tape devices, just files (so you still need the temp space). But maybe that 
can be changed ( I haven't got time to try!).

Hope this helps.

-------------------------  CUT HERE ------------------------------------

#!/bin/csh -f
#
# ztar
#
#	by Curt McDowell (curt@watson.ibm.com), 05-11-92
#
#	Ztar is for people who keep around lots of .tar.Z files.
#	It is like regular tar, except the tar file is always compressed.
#	Do not attempt to use use with tape drives, just .tar.Z files.
#
#	The tar 'f' option (file) is required.  The standard I/O file
#	argument "-" works correctly.  The .Z extension on the filename
#	is automatically added if not present.
#
#	Examples:	ztar tvf file.tar     (or:  ztar tvf file.tar.Z)
#			ztar xvf file.tar
#			ztar cvf - dir | uuencode dir.tar.Z > dir.tar.Z.uue
#

set path=(/bin /usr/bin /usr/ucb)

if ( $#argv < 2 ) then
	sh -c "echo ztar: Missing argument. 1>&2"
	exit 1
endif

set tar_opt=$argv[1]:q

if ( $tar_opt !~ *f* ) then
	sh -c "echo ztar: Use of -f option is required. 1>&2"
	exit 1
endif

if ( $tar_opt =~ *c* ) set comp_output
if ( $tar_opt =~ *r* ) set comp_output
if ( $tar_opt =~ *r* ) set comp_input
if ( $tar_opt =~ *t* ) set comp_input
if ( $tar_opt =~ *u* ) set comp_input
if ( $tar_opt =~ *u* ) set comp_output
if ( $tar_opt =~ *x* ) set comp_input

if ( $argv[2]:e == Z ) set argv[2]=$argv[2]:r

set tar_file=$argv[2]:q

if ( $tar_file:q != "-" &&   $?comp_input && ! $?comp_output || \
     $tar_file:q != "-" && ! $?comp_input &&   $?comp_output ) then
	set argv[2]="-"
	set fake_std
endif

if ( $tar_file:q == "-" && $?comp_input && $?comp_output ) then
#	The following subshell is my way of writing to stderr from csh, sigh.
	sh -c "echo ztar: Cannot use file - with options $tar_opt. 1>&2"
	exit 1
endif

if ( $argv[2]:q == "-" ) then
	if ( $?comp_input ) then
		if ( $?fake_std ) then
			compress -cd $tar_file:q | tar $*:q
			if ( $status != 0 ) exit $status
		else
			compress -cd | tar $*:q
			if ( $status != 0 ) exit $status
		endif
	else
		if ( $?fake_std ) then
			tar $*:q | compress > $tar_file:q.Z
			if ( $status != 0 ) exit $status
		else
			tar $*:q | compress
			if ( $status != 0 ) exit $status
		endif
	endif
else
	if ( $?comp_input ) then
		compress -d $tar_file:q
		if ( $status != 0 ) exit $status
	endif

	tar $*:q
	if ( $status != 0 ) exit $status

	if ( $?comp_output ) then
		compress $tar_file:q
		if ( $status != 0 ) exit $status
	endif
endif

exit 0

-------------------------  CUT HERE ------------------------------------

-- 
Michael Krus.					 Email : krus@cs.concordia.ca
Concordia University				Universite d'Orsay - Paris XI
Montreal, Canada					        Paris, France
A lack of leadership is no substitute for inaction.
Newsgroups: comp.os.linux