X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;ds=sidebyside;f=backup%2Ffull;h=e23890d9dbb605b9ad69e664559cedb9abaaa84e;hb=314a202a6f4e0a120fd982ad0398cdf507d6219d;hp=784d302335e3c3653c6e484cab95fed8125281d4;hpb=c9864d70f390dc1e16c7f1d744f15a2a008f5ce8;p=chiark-utils.git diff --git a/backup/full b/backup/full index 784d302..e23890d 100755 --- a/backup/full +++ b/backup/full @@ -167,6 +167,8 @@ setstatus "FAILED during dump"; 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 @@ -182,32 +184,30 @@ foreach $exc (@excl) { # For each filesystem to be put on this tape: for $tf (@fsys) { printdate(); + parsefsys(); + 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 2>&1"; - 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 $!; + $ddcmd .= " conv=sync"; } - pipe(BUFOR,BUFOW) or die $!; - parsefsys(); - + nexttapefile("full $prefix:$atf"); + # We can back up via dump or cpio or zafio + $dumpin= '&FINDOW',$rstr."find $atf -xdev -noleaf -print0"; $dumpcmd= "cpio -Hustar -o0C$softblocksizebytes"; @@ -218,6 +218,8 @@ for $tf (@fsys) { # don't use verbose flag as this generates 2MB report emails :-> $dumpcmd = "afio -b $softblocksizebytes -Zo -"; $dumpin = '<&FINDOR'; + } elsif ($tm eq 'ntfsimage') { + $dumpcmd= "ntfsimage -vvf --dirty $dev"; } else { die "unknown method $tm for $prefix:$atf\n"; } @@ -225,18 +227,27 @@ for $tf (@fsys) { # to the exit status of all the commands in the pipeline. # It is roughly equivalent to: # md5sum
>this-md5sums - # dump <$dumpin | tee p | writebuffer | dd >/dev/null - startprocess '
>this-md5sums','md5sum'; - startprocess $dumpin,'>&DUMPOW',$rstr.$dumpcmd; - startprocess '<&DUMPOR','>&TEEOW','tee p'; + # 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";
if ($gz) {
- startprocess '<&TEEOR','>&GZOW','gzip -v$gz';
+ startprocess '<&TEEOR','>&GZOW',"$nice gzip -v$gz";
}
- startprocess "<&$bufir",'>&BUFOW','writebuffer';
- startprocess '<&BUFOR','>/dev/null'
- ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
+ startprocess "<&$bufir",'>&BUFOW',"$nasty writebuffer";
+ 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
@@ -251,9 +262,15 @@ system "mt -f $ntape fsf 1"; $? and die $?;
open S,"this-md5sums" or die $!;
for $tf (@fsys) {
printdate();
+ parsefsys();
chomp($orgsum= ); $orgsum =~ s/\ +\-?$//;
$orgsum =~ m/^[0-9a-fA-F]{32}$/i or die "orgsum \`$orgsum' ?";
- chomp($csum= `dd if=$ntape ibs=$blocksizebytes | readbuffer | md5sum`);
+ $cmd= "$nasty dd if=$ntape ibs=$blocksizebytes";
+ $cmd .= " | $nasty readbuffer";
+ $cmd .= " | $nice gzip -vd" if $gz;
+ $cmd .= " | $nice md5sum";
+ pboth(" $cmd\n");
+ chomp($csum= `$cmd`);
$csum =~ s/\ +\-?$//;
$orgsum eq $csum or die "MISMATCH $tf $csum $orgsum\n";
print "checksum ok $csum\t$tf\n" or die $!;
@@ -264,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.