Ferdinando:

There are two Database Methods to do with Backups. There are also various 
commands that you can find in the Language manual on Backup.

- On Backup Startup
- On Backup Shutdown

Within these two is where we put code to ‘Wrap’ the 4D Backup process.

This code is an example of getting the results of the 4D Backup and depending 
on what occurred you record inside the data file, as well as if you want you 
can send out notifications in a manner that you want. We have several ways of 
communicating with our System Administrators.

What we do is in the On Backup Shutdown put in code that gets the details on 
the backup that was just done / attempted.

An Example could be:

// Get Backup Information
GET BACKUP INFORMATION(Last backup date;$vD_BackupDate;$vH_BackupTime)
GET BACKUP INFORMATION(Last backup status;$vL_StatusNum;$vT_Status_Desc)
GET BACKUP INFORMATION(Next backup date;$vD_BackupNextDate;$vH_BackupNextTime)

// Format the Information the way we want it.
$vT_Details:=""
$vT_Details:=$vT_Details+"Last Backup on: "+UTIL_Date_ToString 
($vD_BackupDate)+" at "+UTIL_Time_ToString ($vH_BackupTime)+Char(Carriage 
return)

$vT_Details:=$vT_Details+"Backup status: # "+String($vL_StatusNum)+" - 
"+$vT_Status_Desc+Char(Carriage return)

$vT_Details:=$vT_Details+"Next backup Date: "+UTIL_Date_ToString 
($vD_BackupNextDate)+" at "+UTIL_Time_ToString 
($vH_BackupNextTime)+Char(Carriage return)

If ($1#0)  // There was a problem with the backup

        $vT_LogFilePathname:=Log file

        $vT_4DErrorDesc:=LogDebug_Get4DError ($1)

        REC_Create (->[SEC_Logging])
        [SEC_Logging]Activity:="Backup_Failure"
        [SEC_Logging]Activity_Date:=Current date(*)
        [SEC_Logging]Activity_Time:=UTIL_Timestamp 
        [SEC_Logging]Method:="On Backup Shutdown"
        [SEC_Logging]Details:=String($1)+": "+$vT_4DErrorDesc+Char(Carriage 
return)+$vT_Details
        [SEC_Logging]ActionToDo:="Notify"  // So we know that this has not been 
done yet.
        REC_Save (->[SEC_Logging])




        If (False)  // Cannot be done here because this can occur before the 
startup is done
                If (OB Is defined(<>O_Configuration))

                        If (Num(CONFIG_InfoGet 
("Admin.Backup.Fail_Notification.JMail"))#0)
                                LogDebug_ERROR (Current method name;"Backup 
Fail - JMail Module information not set up.")
                        End if 

                        If (Num(CONFIG_InfoGet 
("Admin.Backup.Fail_Notification.InternalEMail"))#0)
                                LogDebug_ERROR (Current method name;"Backup 
Fail - Internal E-Mail Module information not set up.")
                        End if 

                        If (CONFIG_InfoGet 
("Admin.Backup.Fail_Notification.ExternalEMail")#"")
                                LogDebug_ERROR (Current method name;"Backup 
Fail - External E-Mail Module information not set up.")
                        End if 

                End if   // If (OB Is defined(<>O_Configuration))
        End if   // IF(False) // Cannot be done here because this can occur 
before the startup is do


Else 

        REC_Create (->[SEC_Logging])
        [SEC_Logging]Activity:="Backup_Success"
        [SEC_Logging]Activity_Date:=Current date(*)
        [SEC_Logging]Activity_Time:=UTIL_Timestamp 
        [SEC_Logging]Method:="On Backup Shutdown"
        [SEC_Logging]Details:=$vT_Details
        [SEC_Logging]ActionToDo:="Notify"  // So that we know this has not been 
done yet.
        REC_Save (->[SEC_Logging])


        REC_Create (->[SEC_Logging])
        [SEC_Logging]Activity:="Backup_Success"
        [SEC_Logging]Activity_Date:=Current date(*)
        [SEC_Logging]Activity_Time:=UTIL_Timestamp 
        [SEC_Logging]Method:="On Backup Shutdown"
        [SEC_Logging]Details:=$vT_Details
        [SEC_Logging]ActionToDo:="Load AuditTrail"  // So that we know this has 
not been done yet.
        REC_Save (->[SEC_Logging])




If (OB Is defined(<>O_Configuration))

        If (Num(CONFIG_InfoGet ("Admin.Backup.Success_Notification.JMail"))#0)
                LogDebug_ERROR (Current method name;"Backup Success - JMail 
Module information not set up.")
        End if 

        If (Num(CONFIG_InfoGet 
("Admin.Backup.Success_Notification.InternalEMail"))#0)
                LogDebug_ERROR (Current method name;"Backup Success - Internal 
E-Mail Module information not set up.")
        End if 

        If (CONFIG_InfoGet 
("Admin.Backup.Success_Notification.ExternalEMail")#"")
                LogDebug_ERROR (Current method name;"Backup Success - External 
E-Mail Module information not set up.")
        End if 

                End if   // // If (OB Is defined(<>O_Configuration))
        
End if 



> On Aug 14, 2017, at 4:43 AM, stardata.info via 4D_Tech <[email protected]> 
> wrote:
> 
> I all,
> 
> I'm looking for a way to get a notification when a backup error is
> triggered. Is there a way that i can follow to make a custom code
> that advertise me when this event comes up?
> 
> Thanks
> Ferdinando
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to