chiark / gitweb /
bugfixes
[chiark-utils.git] / backup / full
index c25acc0861762e5c81c4e84784a0cf6c009538e4..784d302335e3c3653c6e484cab95fed8125281d4 100755 (executable)
@@ -30,21 +30,36 @@ 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 '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();
 
 setstatus "FAILED reading TAPEID";
 # Try to read the tape ID from the tape into the file TAPEID
-unlink 'TAPEID';
-system "mt -f $tape rewind"; $? and die $?;
-system "mt -f $tape setblk $blocksizebytes"; $? and die $?;
-system "dd if=$tape bs=${blocksize}b count=10 | tar -b$blocksize -vvxf - TAPEID";
+
+readtapeid_raw();
 
 setstatus "FAILED during startup";
 
@@ -130,14 +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.
-open T, ">TAPEID" or die $!;
-print T "$tapeid\n" or die $!;
-close T or die $!;
 
-system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?;
-system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; $? and die $?;
+writetapeid($tapeid,$tapedesc);
 
 unlink 'this-md5sums';
 
@@ -169,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();
     
@@ -197,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();
@@ -216,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 $!;