3 # check that the configuration is sane and backs up everything it should
5 # This file is part of chiark backup, a system for backing up GNU/Linux and
6 # other UN*X-compatible machines, as used on chiark.greenend.org.uk.
9 # Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
10 # Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
12 # This is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2, or (at your option) any later version.
16 # This is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 # You should have received a copy of the GNU General Public License along
22 # with this program; if not, write to the Free Software Foundation, Inc.,
23 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 # All filesystems must either be backed up in both full and
26 # incremental dumps or listed as exceptions.
29 $etc= '/etc/chiark-backup';
30 require "$etc/settings.pl";
31 require 'backuplib.pl';
36 open X,'last-tape' or die $!;
40 while (!defined $tapedone{$tape}) {
41 open X,"$etc/tape.$tape" or die "$tape $!";
44 $_= <X> or die $1; chomp; s/\s*$//;
48 if (m/^filesystems (\w+)$/) { $fsg= $1; }
49 elsif (m/^next (\w+)$/) { $next=$1; }
50 else { die "$tape $_ ?"; }
52 length $fsg or die "$tape $!";
53 length $next or die "$tape $!";
54 push @{$fsgdone{$fsg}}, $tape;
59 for $fsg (sort keys %fsgdone) {
60 print "filesystem group $fsg: ".join(' ',@{$fsgdone{$fsg}}).":\n ";
65 $pstr= $prefix ne '<local>' ? "$prefix:$atf" : $atf;
66 &e("dumped twice ($backed{$pstr}, $fsg): $pstr")
67 if defined $backed{$pstr};
74 print "incremental group:\n ";
79 $pstr= $prefix ne '<local>' ? "$prefix:$atf" : $atf;
85 for $pfx ('', sort keys %prefix) {
86 $rstr= length($pfx) ? $prefix{$pfx}.' ' : '';
87 $dfstr= exists($prefixdf{$pfx}) ? $prefixdf{$pfx} :
88 'df --no-sync -xiso9660 -xnfs -xproc';
90 open X, "$cmd |" or die $!;
91 $_= <X>; m/^Filesystem/ or die "$cmd => $_ ?";
92 $ppstr= length($pfx) ? $pfx : '<local>';
93 $pstr= length($pfx) ? "$pfx:" : '';
94 print "mount points: $ppstr:";
98 m,^/dev/(\S+)\s.*\s(/\S*)\s*$, or die "$_ ?";
100 $mounted{"$pstr$mp"}="$pstr$dev"; print " $1-$2";
101 if (defined($backto= $backed{"$pstr$mp"})) {
102 if (m,^/dev/\S+\s+\d+\s+(\d+)\s,) {
103 $usedkb{$backto} += $1;
105 $usedkb{$backto} += 0;
106 $unkkb{$backto} .= " + $pstr$mp";
111 $!=0; close(X); $? and die "$? $!";
114 foreach $fsg (keys %usedkb) {
115 print "filesystem group $fsg: $usedkb{$fsg} 1K-blocks$unkkb{$fsg}\n";
118 # We check that all mounted filesystems are dumped and all
119 # filesystems to be dumped are mounted. The expected-diffs
120 # config file allows us to make exceptions.
122 # #expect disk2 to be mounted but not dumped
124 # # CD may or may not be mounted but should not be dumped in either case
127 open Z,"$etc/expected-diffs" or die $!;
129 $_= <Z> or die; chomp; s/\s*$//;
134 print "non-permanent filesystem expected not to be dumped: $_\n";
135 if (defined($mounted{$_})) {
139 &e("expected not to be dumped, but not a mount point: $_")
140 unless defined($mounted{$_});
141 print "filesystem expected not to be dumped: $_\n";
144 &e("non-filesystem expected to be dumped is mounted: $_ on $mounted{$_}")
145 if defined($mounted{$_});
146 $mounted{$_}= 'expected-diffs';
147 print "non-filesystem expected to be dumped: $_\n";
151 for $fs (sort keys %backed) { length($mounted{$fs}) || &e("dumped ($backed{$fs}), not a mount point: $fs"); }
152 for $fs (sort keys %incrd) { length($mounted{$fs}) || &e("increm'd ($incrd{$fs}), not a mount point: $fs"); }
153 for $fs (sort keys %mounted) { length($backed{$fs}) || &e("mount point ($mounted{$fs}), not dumped: $fs"); }
154 for $fs (sort keys %mounted) { length($incrd{$fs}) || &e("mount point ($mounted{$fs}), not increm'd: $fs"); }
156 $emsg.= "configuration ok\n" unless $e;
160 sub e { $emsg.="** @_\n"; $e=1; }