chiark / gitweb /
really packaged
[chiark-utils.git] / backup / full
index e23890d9dbb605b9ad69e664559cedb9abaaa84e..a46726077e414ff1275606931562672a82b4024c 100755 (executable)
@@ -45,6 +45,8 @@ while (@ARGV) {
 # checkallused checks that all the filesystems mounted are in fact
 # dumped in both full and incremental dumps.
 
+openlog();
+
 if (!$nocheck) {
     setstatus "FAILED configuration check";
     print "Configuration check ...\n" or die $!;
@@ -140,14 +142,13 @@ if ($incremental) {
 
 # Read the filesystem group definition (file fsys.nnn)
 readfsys("$fsys");
-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 $?;
+    runsystem("mt -f $tape reten");
 }
 
 setstatus "FAILED writing tape ID";
@@ -219,7 +220,7 @@ for $tf (@fsys) {
         $dumpcmd = "afio -b $softblocksizebytes -Zo -";
         $dumpin = '<&FINDOR';
     } elsif ($tm eq 'ntfsimage') {
-       $dumpcmd= "ntfsimage -vvf --dirty $dev";
+       $dumpcmd= "ntfsimage -svvf --dirty $dev";
     } else {
        die "unknown method $tm for $prefix:$atf\n";
     }
@@ -246,8 +247,8 @@ for $tf (@fsys) {
     close DDERR;
     m/\n(\d+)\+0 records out\n/ or die ">$dderr< ?";
     push @tapefilesizes, [ $1, $currenttapefilename ];
-    $totalrecords++;
-    pboth("total blocks written so far: $totalrecords");
+    $totalrecords += $1;
+    pboth("total blocks written so far: $totalrecords\n");
 }
 
 # The backup should now be complete; verify it
@@ -255,8 +256,8 @@ for $tf (@fsys) {
 setstatus "FAILED during check";
 
 # Rewind the tape and skip the TAPEID record
-system "mt -f $tape rewind"; $? and die $?;
-system "mt -f $ntape fsf 1"; $? and die $?;
+runsystem("mt -f $tape rewind");
+runsystem("mt -f $ntape fsf 1");
 
 # Check the md5sums match for each filesystem on the tape
 open S,"this-md5sums" or die $!;
@@ -277,16 +278,25 @@ for $tf (@fsys) {
     print LOG "checksum ok $csum\t$tf\n" or die $!;
 }
 printdate();
-system "mt -f $tape rewind"; $? and die $?;
+runsystem("mt -f $tape rewind");
 
 setstatus "FAILED during cleanup";
 
-pboth("summary:");
+$summary= '';
 foreach $tfs (@tapefilesizes) {
-    pboth(sprintf "    %10d blocks for %s\n", $tfs->[0], $tfs->[1]);
+    $summary .= 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);
+$summary .=
+    sprintf "    %10d blocks total (of %d bytes) plus TAPEID and headers\n",
+    $totalrecords, $blocksizebytes;
+
+pboth("size-summary:\n");
+pboth($summary);
+
+open SS, ">size-summary..new" or die $!;
+print SS $summary or die $!;
+close SS or die $!;
+rename 'size-summary..new',"size-summary.$fsys" or die $!;
 
 # Write to some status files to indicate what the backup system
 # ought to do when next invoked.