]> andersk Git - moira.git/blobdiff - backup/nightly.sh
*** empty log message ***
[moira.git] / backup / nightly.sh
index 6d166c44911fbcdc04f07ae81b1d2b561bce7872..b6b6ebb8d246762a94387e593fe0da1c6a644a99 100644 (file)
@@ -1,18 +1,23 @@
-#!/bin/sh
+#!/bin/sh -x
 #
-#      Nightly script for backing up SMS.
+#      Nightly script for backing up Moira.
 #
 #
-BKUPDIRDIR=/tmp
-
+BKUPDIRDIR=/u1/backups
+PATH=/bin:/athena/bin:/usr/athena/bin:/usr/bin:/usr/ucb:/usr/new; export PATH
+. /usr/ingres/sqluser.profile
 chdir ${BKUPDIRDIR}
 
+# /moira/bin/counts </dev/null 
+
 if [ -d in_progress ] 
 then
        echo "Two backups running?"
        exit 1
 fi
 
+trap "rm -rf ${BKUPDIRDIR}/in_progress" 0 1 15 
+
 if mkdir in_progress 
 then
        echo "Backup in progress."
@@ -20,19 +25,29 @@ else
        echo "Cannot create backup directory"
        exit 1
 fi
-       
-if /u1/sms/backup/smsbackup ${BKUPDIRDIR}/in_progress/
+chmod 750 in_progress
+if /moira/bin/mrbackup ${BKUPDIRDIR}/in_progress/
 then
+       ftotal=`ls ${BKUPDIRDIR}/in_progress/ | awk '{n++} END {print n}'`
+       fzero=`ls -s ${BKUPDIRDIR}/in_progress/|awk '$1==0{z++} END{print z}'`
+       echo "Dumped $ftotal files, of which $fzero are zero length"
+       if [ "$fzero" -gt 2 ]
+       then
+               echo "Backup was incomplete!"
+               exit 1
+       fi
        echo "Backup successful"
 else
        echo "Backup failed!"
        exit 1
 fi
 
+/moira/bin/report.sh ${BKUPDIRDIR}/in_progress > ${BKUPDIRDIR}/in_progress/report
+
 if [ -d stale ]
 then
        echo -n "Stale backup "
-       rm -rf backup_4
+       rm -r stale
        echo "removed"
 fi
 echo -n "Shifting backups "
@@ -44,9 +59,19 @@ echo -n "2"
 mv backup_1 backup_2
 echo -n "1"
 mv in_progress backup_1
+echo
+/bin/df /moira/moira.log | /usr/ucb/tail -1
 echo 
 echo -n "deleting last backup"
 rm -rf stale
-echo "New backup:"
-ls -l backup_1
+echo "Shipping over the net:"
+rcp -rpx ${BKUPDIRDIR}/* oregano:/u1/moira
+rcp -rpx ${BKUPDIRDIR}/* nessus:/backup/moira
+
+if [ "`/usr/bin/find /moira/critical.log -mtime -1 -print`" = "/moira/critical.log" ]; then
+       (/bin/echo "To: dbadmin";\
+        /bin/echo "Subject: Moira update status";\
+        /usr/ucb/tail /moira/critical.log) | /bin/mail dbadmin
+fi
+
 exit 0
This page took 0.032923 seconds and 4 git commands to generate.