chiark / gitweb /
bugfixes
[chiark-utils.git] / backup / full
index 0861537647647b6d3cbfdb450c8eee12d757cf4d..784d302335e3c3653c6e484cab95fed8125281d4 100755 (executable)
@@ -30,12 +30,29 @@ BEGIN {
 
 $|=1;
 
+while (@ARGV) {
+    $_= shift @ARGV;
+    if (m/^\-\-no\-reten$/) {
+       $noreten=1;
+    } elsif (m/^\-\-no\-config\-check$/) {
+       $nocheck=1;
+    } else {
+       die "unknown option/argument \`$_'\n";
+    }
+}
+
 # Check to see whether the tape.nn and fsys.nn files are sane.
 # checkallused checks that all the filesystems mounted are in fact
 # dumped in both full and incremental dumps.
-setstatus "FAILED configuration check";
-print "Configuration check ...\n" or die $!;
-system 'backup-checkallused'; $? and die $?;
+
+if (!$nocheck) {
+    setstatus "FAILED configuration check";
+    print "Configuration check ...\n" or die $!;
+    system 'backup-checkallused'; $? and die $?;
+} else {
+    setstatus "FAILED rewinding";
+    rewind_raw();
+}
 
 printdate();
 
@@ -128,10 +145,15 @@ openlog();
 $doing= "dump of $fsys to tape $tapedesc in drive $tape";
 print LOG "$doing:\n" or die $!;
 
+if (!$noreten) {
+    setstatus "FAILED retensioning";
+    system "mt -f $tape reten"; $? and die $?;
+}
+
 setstatus "FAILED writing tape ID";
 # First write the tape ID to this tape.
 
-writetapeid($tapeid);
+writetapeid($tapeid,$tapedesc);
 
 unlink 'this-md5sums';
 
@@ -163,6 +185,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();
     
@@ -191,7 +229,10 @@ for $tf (@fsys) {
     startprocess '<p','>>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();
@@ -210,9 +251,10 @@ system "mt -f $ntape fsf 1"; $? and die $?;
 open S,"this-md5sums" or die $!;
 for $tf (@fsys) {
     printdate();
-    chomp($orgsum= <S>);
+    chomp($orgsum= <S>); $orgsum =~ s/\ +\-?$//;
     $orgsum =~ m/^[0-9a-fA-F]{32}$/i or die "orgsum \`$orgsum' ?";
     chomp($csum= `dd if=$ntape ibs=$blocksizebytes | readbuffer | md5sum`);
+    $csum =~ s/\ +\-?$//;
     $orgsum eq $csum or die "MISMATCH $tf $csum $orgsum\n";
     print "checksum ok $csum\t$tf\n" or die $!;
     print LOG "checksum ok $csum\t$tf\n" or die $!;