X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=backup%2Ffull;h=61b62668ef47ba249ad1924690a6674c68786328;hp=e23890d9dbb605b9ad69e664559cedb9abaaa84e;hb=2401434ef9f2a0bff941d7c0a6299b831c471dd2;hpb=314a202a6f4e0a120fd982ad0398cdf507d6219d diff --git a/backup/full b/backup/full index e23890d..61b6266 100755 --- a/backup/full +++ b/backup/full @@ -6,12 +6,13 @@ # other UN*X-compatible machines, as used on chiark.greenend.org.uk. # # chiark backup is: -# Copyright (C) 1997-1998,2000-2001 Ian Jackson +# Copyright (C) 1997-1998,2000-2001,2007 +# Ian Jackson # Copyright (C) 1999 Peter Maydell # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. +# Foundation; either version 3, or (at your option) any later version. # # This is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS @@ -19,8 +20,8 @@ # details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# with this program; if not, consult the Free Software Foundation's +# website at www.fsf.org, or the GNU Project website at www.gnu.org. BEGIN { $etc= '/etc/chiark-backup'; @@ -45,6 +46,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 +143,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"; @@ -160,7 +162,7 @@ unlink 'this-md5sums'; print "Doing $doing ...\n" or die $!; unlink 'p'; -system 'mknod p p'; $? and die $?; +system 'mknod -m600 p p'; $? and die $?; setstatus "FAILED during dump"; @@ -185,6 +187,7 @@ foreach $exc (@excl) { for $tf (@fsys) { printdate(); parsefsys(); + prepfsys(); pipe(FINDOR,FINDOW) or die $!; pipe(DUMPOR,DUMPOW) or die $!; @@ -202,12 +205,13 @@ for $tf (@fsys) { $ddcmd .= " conv=sync"; } - nexttapefile("full $prefix:$atf"); + nexttapefile("full $prefix:$atf_print"); # We can back up via dump or cpio or zafio $dumpin= '&FINDOW',$rstr."find $atf -xdev -noleaf -print0"; $dumpcmd= "cpio -Hustar -o0C$softblocksizebytes"; @@ -219,9 +223,12 @@ for $tf (@fsys) { $dumpcmd = "afio -b $softblocksizebytes -Zo -"; $dumpin = '<&FINDOR'; } elsif ($tm eq 'ntfsimage') { - $dumpcmd= "ntfsimage -vvf --dirty $dev"; + $dumpcmd= "ntfsimage -svvf --dirty $dev"; + } elsif ($tm eq 'gtar') { + execute("$rstr touch $fsidfile+new"); + $dumpcmd= "tar Ccfl $atf - ."; } else { - die "unknown method $tm for $prefix:$atf\n"; + die "unknown method $tm for $prefix:$atf_print\n"; } # This is a funky way of doing a pipeline which pays attention # to the exit status of all the commands in the pipeline. @@ -246,8 +253,14 @@ 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"); + + if ($tm eq 'gtar') { + execute("$rstr mv -f $fsidfile+new $fsidfile"); + } + + finfsys(); } # The backup should now be complete; verify it @@ -255,8 +268,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 +290,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.