]> andersk Git - moira.git/blame - backup/nightly.sh
In the past year, added: /mit/info/public-mailing-lists maintained
[moira.git] / backup / nightly.sh
CommitLineData
4e491e19 1#!/bin/sh
dec49b94 2#
585a86c3 3# Nightly script for backing up Moira.
dec49b94 4#
5#
4e491e19 6BKUPDIRDIR=/backup
127b93bf 7PATH=/bin:/athena/bin:/usr/athena/bin:/usr/bin:/usr/ucb:/usr/new; export PATH
8a9c2b77 8. /usr/ingres/sqluser.profile
dec49b94 9chdir ${BKUPDIRDIR}
10
1b084388 11# /moira/bin/counts </dev/null
f3a05e0e 12
dec49b94 13if [ -d in_progress ]
14then
15 echo "Two backups running?"
16 exit 1
17fi
18
f3a05e0e 19trap "rm -rf ${BKUPDIRDIR}/in_progress" 0 1 15
20
dec49b94 21if mkdir in_progress
22then
23 echo "Backup in progress."
24else
25 echo "Cannot create backup directory"
26 exit 1
27fi
8a9c2b77 28chmod 750 in_progress
1b084388 29if /moira/bin/mrbackup ${BKUPDIRDIR}/in_progress/
dec49b94 30then
4e491e19 31 failed=`ls -s ${BKUPDIRDIR}/in_progress/ \
32 | awk ' !/total/ {
33 if ( FILENAME ~ /conf$/ ) {
34 minsize[$2]=$1;
35 } else {
36 size[$2]=$1
37 }
38 }
39 END {
40 for ( i in minsize ) {
41 if ( minsize[i] > size[i] ) {
42 j+=1
43 }
44 }
45 print j
46 }' ${BKUPDIRDIR}/conf -`
47 if [ "$failed" -gt 0 ]
a6be540b 48 then
4e491e19 49 echo "Backup was incomplete! $failed table(s) too small!"
50 echo "Current file sizes:"
51 ls -s in_progress/
a6be540b 52 exit 1
53 fi
dec49b94 54 echo "Backup successful"
55else
56 echo "Backup failed!"
57 exit 1
58fi
59
ece660ea 60/moira/bin/report.sh ${BKUPDIRDIR}/in_progress > ${BKUPDIRDIR}/in_progress/report
1b084388 61
dec49b94 62if [ -d stale ]
63then
64 echo -n "Stale backup "
f3a05e0e 65 rm -r stale
dec49b94 66 echo "removed"
67fi
68echo -n "Shifting backups "
69
70mv backup_3 stale
4e491e19 71echo -n "3 "
dec49b94 72mv backup_2 backup_3
4e491e19 73echo -n "2 "
dec49b94 74mv backup_1 backup_2
4e491e19 75echo -n "1 "
dec49b94 76mv in_progress backup_1
38a4403b 77echo
78/bin/df /moira/moira.log | /usr/ucb/tail -1
dec49b94 79echo
80echo -n "deleting last backup"
81rm -rf stale
4e491e19 82echo
83echo "Shipping over the net"
84rcp -rpx ${BKUPDIRDIR}/* oregano:/backup
a6be540b 85rcp -rpx ${BKUPDIRDIR}/* nessus:/backup/moira
d323bcdd 86
1b084388 87if [ "`/usr/bin/find /moira/critical.log -mtime -1 -print`" = "/moira/critical.log" ]; then
d323bcdd 88 (/bin/echo "To: dbadmin";\
89 /bin/echo "Subject: Moira update status";\
1b084388 90 /usr/ucb/tail /moira/critical.log) | /bin/mail dbadmin
d323bcdd 91fi
92
4e491e19 93plfile=/afs/athena.mit.edu/system/info/public-mailing-lists
94awk -F\| '$3==1 && $4==1 && $5==0 && $6==1 {printf "%-20s %s\n", $1, $9}' \
95 ${BKUPDIRDIR}/backup_1/list \
96 | sort > $plfile.new && mv -f $plfile.new $plfile
97
dec49b94 98exit 0
This page took 0.120168 seconds and 5 git commands to generate.