]> andersk Git - moira.git/blob - backup/nightly.sh
de0121c21bb285fe7e420bfb669bdb4e2a9eb71e
[moira.git] / backup / nightly.sh
1 #!/bin/sh -x
2 #
3 #       Nightly script for backing up Moira.
4 #
5 #
6 BKUPDIRDIR=/u1/backups
7 PATH=/bin:/athena/bin:/usr/athena/bin:/usr/bin:/usr/ucb:/usr/new; export PATH
8 . /usr/ingres/sqluser.profile
9 chdir ${BKUPDIRDIR}
10
11 # /moira/bin/counts </dev/null  
12
13 if [ -d in_progress ] 
14 then
15         echo "Two backups running?"
16         exit 1
17 fi
18
19 trap "rm -rf ${BKUPDIRDIR}/in_progress" 0 1 15 
20
21 if mkdir in_progress 
22 then
23         echo "Backup in progress."
24 else
25         echo "Cannot create backup directory"
26         exit 1
27 fi
28 chmod 750 in_progress
29 if /moira/bin/mrbackup ${BKUPDIRDIR}/in_progress/
30 then
31         echo "Backup successful"
32 else
33         echo "Backup failed!"
34         exit 1
35 fi
36
37 /moira/bin/report.sh ${BKUPDIRDIR}/in_progress > ${BKUPDIRDIR}/in_progress/report
38
39 if [ -d stale ]
40 then
41         echo -n "Stale backup "
42         rm -r stale
43         echo "removed"
44 fi
45 echo -n "Shifting backups "
46
47 mv backup_3 stale
48 echo -n "3"
49 mv backup_2 backup_3
50 echo -n "2"
51 mv backup_1 backup_2
52 echo -n "1"
53 mv in_progress backup_1
54 echo 
55 echo -n "deleting last backup"
56 rm -rf stale
57 echo "Shipping over the net:"
58 rcp -rp ${BKUPDIRDIR}/* oregano:/u1/moira
59 rcp -rp ${BKUPDIRDIR}/* nessus:/backup/moira
60
61 if [ "`/usr/bin/find /moira/critical.log -mtime -1 -print`" = "/moira/critical.log" ]; then
62         (/bin/echo "To: dbadmin";\
63          /bin/echo "Subject: Moira update status";\
64          /usr/ucb/tail /moira/critical.log) | /bin/mail dbadmin
65 fi
66
67 exit 0
This page took 0.288898 seconds and 3 git commands to generate.