Re: Modification to handle dar's exit code 11

Torsten Bronger <[email protected]> Sun, 20 Jan 2008 17:09:42 +0100
Newsgroups gmane.comp.sysutils.backup.sarab
Organization Phoenix Foundation
Message-ID <[email protected]>
--=-=-=
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hall=F6chen!

Torsten Bronger writes:

> Hall=F6chen!
>
> Michael Leies writes:
>
>> I've modified sarab.sh to better handle Dar's exit codes, well at
>> least exit code 11, perhaps it will be of use to some one else.
>>
>> [...]
>>
>> the modified script is attached, the original is version 0.2.2.
>> you may need to excuse my script coding as, i don't play with
>> shell scripts very often.
>
> Please send it again; it didn't get through.

Okay the patch is attached.  I installed it on my local system.
Please test it.  After a couple of weeks, we can update the SaraB
tar ball I think, and add at least the "--go-into" patch, too.

Tsch=F6,
Torsten.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment; filename=sarab.patch
Content-Description: patch for sarab.sh

--- /usr/local/sarab/sarab.sh	2007-11-03 09:22:29.000000000 +0100
+++ /home/bronger/temp/sarab.sh	2008-01-20 16:07:05.000000000 +0100
@@ -212,12 +212,26 @@
 verbose
 verbose "$DAR_COMMAND $REFERENCE_BASENAME"
 $DAR_COMMAND $REFERENCE_BASENAME
-if [ "$?" != "0" ]; then
-   echo "ERROR: Error when executing the backup with DAR. The attempted command was... "
+DAR_EXIT=$?
+
+# If DAR exits with a non zero, but not 11 exit code then a serious 
+# error occured.  Record the error and exit.
+if [ "$DAR_EXIT" != "0" ] && [ "$DAR_EXIT" != "11" ]; then
+   echo "ERROR: (Exit code: $DAR_EXIT)Error when executing the backup with DAR. The attempted command was... "
    echo "$DAR_COMMAND $REFERENCE_BASENAME"
    exit 1
 fi
 
+# If DAR exits with error code 11, a file was modified during the backup
+# process, which is more of a warning than a serious error, although it
+# sort of depends on what you are backing up.  So log it but don't exit,
+# which allows SarahB to continue, because exiting here causes the whole
+# backup to be lost which is worse than one bad file.
+if [ "$DAR_EXIT" == "11" ]; then
+    echo "A file was modified during the backup process."
+fi
+
+
 # If configured, test the new archive for errors before removing old archive.
 if [ $TEST_ARCHIVE = "yes" ]; then
    echo
@@ -307,6 +321,11 @@
 echo "The backup process took $HOURS hours, $MINUTES minutes and $SECONDS seconds."
 echo "****************************************************************************"
 
+## If DAR exits with code 11 then ensure a warning email is sent
+if [ "$DAR_EXIT" == "11" ]; then
+    exit 2
+fi
+
 }
 
 ########################################################################
@@ -376,8 +395,15 @@
    cat $TEMP_LOG | mail -s "SaraB: Successful backup for $DATE" "$EMAIL_ADDRESS"
 fi
 
+## Warn the user that a file was modified during the backup and may be
+## corrupt.
+if [ "$EMAIL_SUCCESS" = "yes" ] && [ "$MAIN_EXIT" = "2" ]; then
+   cat $TEMP_LOG | mail -s "SaraB: Warning during backup for $DATE" "$EMAIL_ADDRESS"
+fi
+
+
 ## If notification of failure is desired, send notification email
-if [ "$EMAIL_FAILURE" = "yes" ] && [ "$MAIN_EXIT" != "0" ]; then
+if [ "$EMAIL_FAILURE" = "yes" ] && [ "$MAIN_EXIT" != "0" ] && [ "$MAIN_EXIT" != "2" ] ; then
    cat $TEMP_LOG | mail -s "SaraB: Backup failure for $DATE" "$EMAIL_ADDRESS"
 fi
 

--=-=-=


-- 
Torsten Bronger, aquisgrana, europa vetus
                                      Jabber ID: [email protected]
               (See http://ime.webhop.org for further contact info.)

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
SaraB-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sarab-discuss

--=-=-=--