chiark / gitweb /
from lalonde
[chiark-utils.git] / backup / driver
1 #!/bin/sh
2 # driver
3 # entry point for inittab (or perhaps cron) to run the backups.
4 #
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.
7 #
8 # chiark backup is:
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>
11 #
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.
15 #
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
19 # details.
20 #
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.
24
25 cd /var/lib/chiark-backup
26 PATH=/usr/share/chiark-backup:$PATH export PATH
27
28 if [ "x$1" != test ]; then
29         stty sane
30         stty -isig
31 fi
32
33 rm -f this-status p p2
34 echo 'FAILED to start dump script' >this-status
35
36 # Here we go : run 'full', which (name notwithstanding) handles
37 # both full and incremental backups, according to the ID of the
38 # tape in the drive.
39 full 2>&1 | tee this-log
40
41 status=`cat this-status 2>/dev/null`
42
43 # Mail a report to somewhere appropriate; -odq removed (means just 
44 # queue message, don't try to deliver) because it just delays the
45 # message (you might want that if mail was one of the services turned
46 # off for the duration of the backup, though).
47 cat <<END - this-log | /usr/lib/sendmail -oi -om -oee -t
48 To: dump-reports
49 Subject: Dump Report: $status
50
51 END
52
53 rm -f /TAPEID
54
55 if [ "x$1" != test ]; then
56         # Bring the system up as multiuser again
57         bringup
58         stty isig
59 fi