chiark / gitweb /
From Peter Maydell (/u2/pmaydell/iwjbackup/) as per <E156bwm-0005xq-00@watchdragon...
[chiark-utils.git] / backup / checkallused
index fd613f3181b75d91c5fc603c70f510ad40ee2337..f50abb7aef4268369715dde75cb44cead2c6f067 100755 (executable)
@@ -1,5 +1,9 @@
 #!/usr/bin/perl
 
+# Read all the configuration files and check that all filesystems
+# are either backed up in both full and incremental dumps or 
+# listed as exceptions.
+
 BEGIN {
     $etc= '/etc/backup';
     require "$etc/settings.pl";
@@ -38,8 +42,6 @@ for $fsg (sort keys %fsgdone) {
     for $tf (@fsys) {
        parsefsys();
        $pstr= $prefix ne '<local>' ? "$prefix:$atf" : $atf;
-       &e("dumped twice ($backed{$pstr}, $fsg): $pstr")
-           if defined $backed{$pstr};
        $backed{$pstr}= $fsg;
        print " $pstr";
     }
@@ -59,36 +61,28 @@ print "\n";
 
 for $pfx ('', sort keys %prefix) {
     $rstr= length($pfx) ? $prefix{$pfx}.' ' : '';
-    $dfstr= exists($prefixdf{$pfx}) ? $prefixdf{$pfx} :
-       'df --no-sync -xiso9660 -xnfs -xproc';
-    $cmd= "$rstr $dfstr";
-    open X, "$cmd |" or die $!;
-    $_= <X>; m/^Filesystem/ or die "$cmd => $_ ?";
+    open X, $rstr." df --no-sync -xnfs |" or die $!;
+    $_= <X>; m/^Filesystem/ or die "$_ ?";
     $ppstr= length($pfx) ? $pfx : '<local>';
     $pstr= length($pfx) ? "$pfx:" : '';
     print "mount points: $ppstr:";
     while (<X>) {
        chomp;
-       next if m,^procfs\s,;
        m,^/dev/(\S+)\s.*\s(/\S*)\s*$, or die "$_ ?";
-       ($dev,$mp) = ($1,$2);
-       $mounted{"$pstr$mp"}="$pstr$dev"; print " $1-$2";
-       if (defined($backto= $backed{"$pstr$mp"})) {
-           if (m,^/dev/\S+\s+\d+\s+(\d+)\s,) {
-               $usedkb{$backto} += $1;
-           } else {
-               $usedkb{$backto} += 0;
-               $unkkb{$backto} .= " + $pstr$mp";
-           }
-       }
+       $mounted{"$pstr$2"}="$pstr$1"; print " $1-$2";
     }
     print "\n";
-    $!=0; close(X); $? and die "$cmd $? $!";
 }
+$!=0; close(X); $? and die "$? $!";
 
-foreach $fsg (keys %usedkb) {
-    print "filesystem group $fsg: $usedkb{$fsg} 1K-blocks$unkkb{$fsg}\n";
-}
+# We check that all mounted filesystems are dumped and all
+# filesystems to be dumped are mounted. The expected-diffs
+# config file allows us to make exceptions.
+# eg: 
+# #expect disk2 to be mounted but not dumped
+# !/disk2
+# # CD may or may not be mounted but should not be dumped in either case
+# ?/cdrom
 
 open Z,"$etc/expected-diffs" or die $!;
 for (;;) {
@@ -96,7 +90,12 @@ for (;;) {
     last if m/^end$/;
     next unless m/^\S/;
     next if m/^\#/;
-    if (s/^\!//) {
+    if (s/^\?//) {
+        print "non-permanent filesystem expected not to be dumped: $_\n";
+        if (defined($mounted{$_})) {
+            delete $mounted{$_};
+        }
+    } elsif (s/^\!//) {
        &e("expected not to be dumped, but not a mount point: $_")
            unless defined($mounted{$_});
         print "filesystem expected not to be dumped: $_\n";