# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
BEGIN {
- $etc= '/etc/backup';
+ $etc= '/etc/chiark-backup';
require "$etc/settings.pl";
require 'backuplib.pl';
}
$|=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";
$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';
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();
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();
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 $!;