From f163dbe381968d1ad2fc8fd13455e7b5fb03bdf5 Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Mon, 5 May 2003 16:39:10 +0000 Subject: [PATCH] first cut of gz support --- backup/backuplib.pl | 27 +++++++++++++++++++++------ backup/full | 21 ++++++++++++++++++++- debian/changelog | 4 ++-- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/backup/backuplib.pl b/backup/backuplib.pl index f8d7349..c2c7e81 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -140,22 +140,37 @@ sub readfsys ($) { # Parse a line from a filesystem definition file. We expect the line # to be in $tf. sub parsefsys () { - if ($tf =~ m,^(/\S*)\s+(\w+)$,) { - # Line of form '/file/system dumptype' + my ($dopts,$dopt); + if ($tf =~ m,^(/\S*)\s+(\w+)([,0-9a-z]+)$,) { + # Line of form '/file/system dumptype[,options]' $atf= $1; $tm= $2; + $dopts= $3; $prefix= ''; stat $atf or die "stat $atf: $!"; -d _ or die "not a dir: $atf"; $rstr= ''; - } elsif ($tf =~ m,^(/\S*)\s+(\w+)\s+(\w+)$,) { - # Line of form '/file/system dumptype prefix' - # (used for remote backups, I think) + } elsif ($tf =~ m,^(/\S*)\s+(\w+)([,0-9a-z]+)\s+(\w+)$,) { + # Line of form '/file/system dumptype[,options] prefix' + # (used for remote backups) $atf= $1; $tm= $2; - $prefix= $3; + $dopts= $3; + $prefix= $4; defined($prefix{$prefix}) or die "prefix $prefix in $tf ?\n"; $rstr= $prefix{$prefix}.' '; + } else { + die "fsys $tf ?"; + } + undef %dopt; + foreach $dopt (split /\,/,$dopts) { + if (grep { $dopt eq $_ } qw(gz)) { + $dopt{$dopt}= 'y'; + } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz)) { + $dopt{$`}= $'; + } else { + die "unknown option $dopt"; + } } } diff --git a/backup/full b/backup/full index 388270f..5d210af 100755 --- a/backup/full +++ b/backup/full @@ -166,6 +166,22 @@ for $tf (@fsys) { pipe(FINDOR,FINDOW) or die $!; pipe(DUMPOR,DUMPOW) or die $!; pipe(TEEOR,TEEOW) or die $!; + $bufir='TEEOR'; + + if ($dopt{'gz'} eq 'y') { + $gz= '3'; + } elsif ($dopt{'gz'} =~ m/^\d$/) { + $gz= $dopt{'gz'}; + } elsif (defined $dopt{'gz'}) { + die "$tf bad gz"; + } else { + $gz= 0; + } + if ($gz) { + $bufir='GZOR'; + pipe(GZOR,GZOW) or die $!; + } + pipe(BUFOR,BUFOW) or die $!; parsefsys(); @@ -194,7 +210,10 @@ for $tf (@fsys) { startprocess '>this-md5sums','md5sum'; startprocess $dumpin,'>&DUMPOW',$rstr.$dumpcmd; startprocess '<&DUMPOR','>&TEEOW','tee p'; - startprocess '<&TEEOR','>&BUFOW','writebuffer'; + if ($gz) { + startprocess '<&TEEOR','>&GZOW','gzip -v$gz'; + } + startprocess '<&$bufir','>&BUFOW','writebuffer'; startprocess '<&BUFOR','>/dev/null' ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape"; closepipes(); diff --git a/debian/changelog b/debian/changelog index bd0438b..90b16ec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -chiark-utils (3.0.4) unstable; urgency=low +chiark-utils (3.0.3.99) unstable; urgency=low * chiark-backup: full dumps have tapedesc in TAPEID - -- + -- Ian Jackson Mon, 5 May 2003 17:09:40 +0100 chiark-utils (3.0.3) unstable; urgency=low -- 2.30.2