From: ianmdlvl Date: Sun, 11 May 2003 20:11:52 +0000 (+0000) Subject: @@ -6,8 +6,11 @@ X-Git-Tag: branchpoint-trivsoundd~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=314a202a6f4e0a120fd982ad0398cdf507d6219d @@ -6,8 +6,11 @@ * ntfsimage support. * fix writebuffer's progname. * fix reporting of unaccountable filesystems. + * A little less clone-and-hack. + * Count and display on-tape file numbers. + * Count output blocks for each tape file and in total. - -- Ian Jackson Sun, 11 May 2003 20:36:20 +0100 + -- chiark-utils (3.0.3) unstable; urgency=low --- diff --git a/TODO b/TODO index caa5dd4..8307b9b 100644 --- a/TODO +++ b/TODO @@ -3,11 +3,10 @@ BACKUP would be nice someday --------------------- -record file number -record bytes written increms after fulls replace loaded with idformat read/writebuffer setuid --mlock whatsthis no cloneandhack +increm no cloneandhack whatsthis listing for zafio and dump archives configuration files autogenerator diff --git a/backup/backuplib.pl b/backup/backuplib.pl index 50cc70a..783b14d 100644 --- a/backup/backuplib.pl +++ b/backup/backuplib.pl @@ -66,11 +66,28 @@ sub readtapeid_raw () { "| tar -b$blocksize -vvxf - TAPEID"; } +sub pboth ($) { + my ($str) = @_; + print LOG $str or die $!; + print $str or die $!; +} + +sub nexttapefile ($) { + my ($what) = @_; + $currenttapefilenumber++; + $currenttapefilename= $what; + pboth(sprintf "writing tape file #%d (mt fsf %d): %s", + $currenttapefilenumber, $currenttapefilenumber-1, $what); +} + sub writetapeid ($$) { open T, ">TAPEID" or die $!; print T "$_[0]\n$_[1]\n" or die $!; close T or die $!; + $currenttapefilenumber= 0; + nexttapefile('TAPEID'); + system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?; system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; $? and die $?; @@ -84,8 +101,7 @@ sub endprocesses () { delete $processes{$p}; $? && die "error: command gave code $?: $c\n"; } - print LOG " ok\n" or die $!; - print " ok\n" or die $!; + pboth(" ok\n"); } sub killprocesses { diff --git a/backup/full b/backup/full index c25f2d0..e23890d 100755 --- a/backup/full +++ b/backup/full @@ -168,6 +168,7 @@ sub closepipes () { close(DUMPOR); close(TEEOR); close(BUFOR); close(FINDOR); close(DUMPOW); close(TEEOW); close(BUFOW); close(FINDOW); close(GZOR); close(GZOW); + close(DDERRR); close(DDERRW); } # work out a find option string that will exclude the required files @@ -188,10 +189,12 @@ for $tf (@fsys) { pipe(FINDOR,FINDOW) or die $!; pipe(DUMPOR,DUMPOW) or die $!; pipe(TEEOR,TEEOW) or die $!; + pipe(TEEOR,TEEOW) or die $!; pipe(BUFOR,BUFOW) or die $!; + pipe(DDERRR,DDERRW) or die $!; $bufir='TEEOR'; - $ddcmd= "dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape"; + $ddcmd= "dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape 2>&1"; if ($gz) { $bufir='GZOR'; @@ -199,6 +202,8 @@ for $tf (@fsys) { $ddcmd .= " conv=sync"; } + nexttapefile("full $prefix:$atf"); + # We can back up via dump or cpio or zafio $dumpin= '>this-md5sums # dump <$dumpin | tee p [| gzip] | writebuffer | dd >/dev/null + startprocess '>this-md5sums',"$nice md5sum"; startprocess $dumpin,'>&DUMPOW',"$nice ".$rstr.$dumpcmd; startprocess '<&DUMPOR','>&TEEOW',"$nice tee p"; @@ -230,9 +236,18 @@ for $tf (@fsys) { startprocess '<&TEEOR','>&GZOW',"$nice gzip -v$gz"; } startprocess "<&$bufir",'>&BUFOW',"$nasty writebuffer"; - startprocess '<&BUFOR','>/dev/null',"$nasty $ddcmd"; + startprocess '<&DDERRR','>/dev/null',"$nice tee dderr >&2"; + startprocess '<&BUFOR','>&DDERRW',"$nasty $ddcmd"; closepipes(); endprocesses(); + + open DDERR, "dderr" or die $!; + defined(read DDERR,$_,1023) or die $!; + close DDERR; + m/\n(\d+)\+0 records out\n/ or die ">$dderr< ?"; + push @tapefilesizes, [ $1, $currenttapefilename ]; + $totalrecords++; + pboth("total blocks written so far: $totalrecords"); } # The backup should now be complete; verify it @@ -254,8 +269,7 @@ for $tf (@fsys) { $cmd .= " | $nasty readbuffer"; $cmd .= " | $nice gzip -vd" if $gz; $cmd .= " | $nice md5sum"; - print LOG " $cmd\n" or die $!; - print " $cmd\n" or die $!; + pboth(" $cmd\n"); chomp($csum= `$cmd`); $csum =~ s/\ +\-?$//; $orgsum eq $csum or die "MISMATCH $tf $csum $orgsum\n"; @@ -267,6 +281,13 @@ system "mt -f $tape rewind"; $? and die $?; setstatus "FAILED during cleanup"; +pboth("summary:"); +foreach $tfs (@tapefilesizes) { + pboth(sprintf " %10d blocks for %s\n", $tfs->[0], $tfs->[1]); +} +pboth(sprintf " %10d blocks total (of %d bytes) plus TAPEID and headers\n", + $totalrecords, $blocksizebytes); + # Write to some status files to indicate what the backup system # ought to do when next invoked. # reset incremental backup count to 1. diff --git a/backup/increm b/backup/increm index 9bad0f1..bc058f7 100755 --- a/backup/increm +++ b/backup/increm @@ -67,14 +67,10 @@ $advance =~ m/^\d+$/ or die "$advance ?"; # it invoked us, so no need to read the existing TAPEID record first.) system "mt -f $ntape rewind"; $? and die $?; if ($advance == 1) { - open TI,">TAPEID" or die $!; - print TI "$tapeid\n$tapedesc\n" or die $!; - close TI 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); } else { system "mt -f $ntape fsf $advance"; $? and die $?; + $currenttapefilenumber= $advance+1; } # Get a list of all filesystems @@ -112,6 +108,9 @@ for $tf (@fsys) { print LOG "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!; next; } + + nexttapefile("inc $prefix:$atf"); + # Same trick as full uses to do a pipeline whilst keeping track # of all exit statuses: # dump /dev/null diff --git a/debian/changelog b/debian/changelog index 0248911..aad37c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,8 +6,11 @@ chiark-utils (3.0.3.99) unstable; urgency=low * ntfsimage support. * fix writebuffer's progname. * fix reporting of unaccountable filesystems. + * A little less clone-and-hack. + * Count and display on-tape file numbers. + * Count output blocks for each tape file and in total. - -- Ian Jackson Sun, 11 May 2003 20:36:20 +0100 + -- Ian Jackson Sun, 11 May 2003 21:11:49 +0100 chiark-utils (3.0.3) unstable; urgency=low