projekty: server-backups/backup - correct - add error report

wolvverine wolvverine at pld-linux.org
Tue Feb 28 04:07:02 CET 2006


Author: wolvverine                   Date: Tue Feb 28 03:07:02 2006 GMT
Module: projekty                      Tag: HEAD
---- Log message:
- correct
- add error report

---- Files affected:
projekty/server-backups:
   backup (1.7 -> 1.8) 

---- Diffs:

================================================================
Index: projekty/server-backups/backup
diff -u projekty/server-backups/backup:1.7 projekty/server-backups/backup:1.8
--- projekty/server-backups/backup:1.7	Mon Feb 27 14:29:48 2006
+++ projekty/server-backups/backup	Tue Feb 28 04:06:57 2006
@@ -49,7 +49,8 @@
 ERROR=$? ;	
 if [ ! ${ERROR} -eq 0 ];
     then
-	/bin/mail -s "backup error - wake host  - $DATA-$TIME !!!!" $RECIPIENT ;
+	echo "backup error ${ERROR}- wake host  - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
+	${PROGMAIL} -s "backup error ${ERROR}- wake host  - $DATA-$TIME !!!!" $RECIPIENT ;
 fi
 ##################
 # backup katalogow
@@ -60,6 +61,7 @@
     nice -n $NICELEVEL ${PROGTAR} ${TAROPT} "${BCK_HOME}/${DATA}-${TIME}/${NAMEDIR}_${DATA}-${TIME}.tar.gz" -X "${EXCLUDEFILE}" "${BACKDIR}"
     ERROR=$?;
 	if [ ! ${ERROR} -eq 0 ]; then
+	    echo "backup error ${ERROR}-${NAMEDIR}-tar.gz  - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
             cat /tmp/$DATA-$TIME-backup |  ${PROGMAIL} -s "backup error ${ERROR}-${NAMEDIR}-tar.gz  - $DATA-$TIME !!!!" $RECIPIENT ;
 	fi
 done < ${CONFBACKDIRFILE}
@@ -80,12 +82,14 @@
 		nice -n $NICELEVEL ${PROGTAR} ${TAROPT} "${BCK_HOME}/${DATA}-${TIME}/${DIRNAME}_${SUBDIRNAME}_${DATA}-${TIME}.tar.gz" -X "${EXCLUDEFILE}" "${SUBDIR}";
 		ERROR=$?;
 		if [ ! ${ERROR} -eq 0 ]; then
+		    echo "backup error ${ERROR} - ${DIRNAME} - ${SUBDIRNAME} - tar.gz  - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
 		    cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - ${DIRNAME} - ${SUBDIRNAME} - tar.gz  - $DATA-$TIME !!!!" $RECIPIENT ;
 		fi
             done
 done < ${CONFBACKSUBDIRFILE}
 ERROR=$?;
 if [ ! ${ERROR} -eq 0 ]; then
+	echo "backup error ${ERROR} - tar.gz  - ${DATA-$TIME} !!!!" >> /tmp/$DATA-$TIME-backup-error
 	cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - tar.gz  - ${DATA-$TIME} !!!!" ${RECIPIENT} ;
 fi
 
@@ -95,6 +99,11 @@
 
 if [ $2 -eq mysql ]; then
     mysqldump -u ${MYSQLUSER}  --password=${MYSQLPASSWORD} -A | gzip -c9 > "${BCK_HOME}/${DATA}-${TIME}/mysql_base_full-${DATA}-${TIME}.gz"
+    ERROR=$?
+    if [ ! ${ERROR} -eq 0 ]; then
+	echo "backup error ${ERROR} - Backup MySQL database - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
+	cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - Backup MySQL database - $DATA-$TIME !!!!" $RECIPIENT ;
+    fi
 fi
 
 #################
@@ -108,12 +117,11 @@
     nice -n $NICELEVEL rsync -avzrp --stats  --password-file="${DIRETC}/rsyncpasswd" "${BCK_HOME}/$DATA-$TIME" $USERSTORHOST@$STORHOST::$DIRSTORHOST  >> /tmp/$DATA-$TIME-backup 1<&2
     ERROR=$?
     if [ ! ${ERROR} -eq 0 ]; then
-	cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - send to another host - $DATA-$TIME !!!!" $RECIPIENT ;
+	echo "backup error ${ERROR} - send rsync to another host - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
+	cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - send rsync to another host - $DATA-$TIME !!!!" $RECIPIENT ;
     fi
-    du -h ${BCK_HOME}/*${DATA}-${TIME}* > ${DIRSCRIPTS}/backup-usage
-    cat "${DIRSCRIPTS}/backup-usage" >> /tmp/$DATA-$TIME-backup
-    cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup OK - $DATA-$TIME" $RECIPIENT
 fi
+########################### END rsync
 
 #########################
 # Nagranie na plytke DVD
@@ -123,6 +131,7 @@
     mkisofs -o "/var/tmp/backup-${DATA}-${TIME}.iso" -J -r -V "Backup_${DATA}-${TIME}" "/var/kopie/${DATA}-${TIME}"
     ERROR=$?;
         if [ ! ${ERROR} -eq 0 ]; then
+	    echo "backup error ${ERROR} - mkiso - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
 	    cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - mkiso - $DATA-$TIME !!!!" $RECIPIENT ;
         fi
     du -h /tmp/backup-$DATA-$TIME.iso >> $DIRSCRIPTS/backup-usage 
@@ -130,16 +139,30 @@
     dvdrecord -dao speed=2 dev=ATAPI:0,1,0 driveropts=burnfree /var/tmp/backup-$DATA-$TIME.iso
     ERROR=$?;
 	if [ ! ${ERROR} -eq 0 ]; then
+	    echo "backup error ${ERROR} - dvdrecord - $DATA-$TIME !!!!" >> /tmp/$DATA-$TIME-backup-error
 	    cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup error ${ERROR} - dvdrecord - $DATA-$TIME !!!!" $RECIPIENT ;
 	fi
-#######################
+    rm /var/tmp/backup-$DATA-$TIME.iso;
+fi
+######################## END dvd
 
+##TODO clean this
+    du -h ${BCK_HOME}/*${DATA}-${TIME}* > ${DIRSCRIPTS}/backup-usage
     echo "$DATA-$TIME" > $DIRSCRIPTS/backup-date
-    echo "$DATA-$TIME - ok" >> /var/log/backup-error	
-    rm /var/tmp/backup-$DATA-$TIME.iso;
+
+###reports backup OK or ERRORS
+if  [ -f /tmp/$DATA-$TIME-backup-error ]; then
+	cat "${DIRSCRIPTS}/backup-usage" >> /tmp/$DATA-$TIME-backup-error
+	cat /tmp/$DATA-$TIME-backup-error | ${PROGMAIL} -s "backup ERROR !!! - $DATA-$TIME" $RECIPIENT
+    else
+        cat "${DIRSCRIPTS}/backup-usage" >> /tmp/$DATA-$TIME-backup
+	echo "$DATA-$TIME - ok" >> /var/log/backups
+	cat /tmp/$DATA-$TIME-backup | ${PROGMAIL} -s "backup OK - $DATA-$TIME" $RECIPIENT
 fi
 
+
 ##############################################################
 #net rpc shutdown -S "$STORHOST" -U "$USERSTORHOST"%"$PASSWD"
 ##############################################################
+
 #EOF
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/projekty/server-backups/backup?r1=1.7&r2=1.8&f=u



More information about the pld-cvs-commit mailing list