How can we help you today? How can we help you today?

Comfirming param for failure email on a restore job

I know you have to manually edit the restore job -- what's the param to use for an email on failture during a restore? Is the the same as the backup? (MAILTO_ONERROR)

The restore job is --

DECLARE @errorCode INT
DECLARE @sqlerrorCode INT
EXECUTE master..sqlbackup N'-SQL "RESTORE LOG [WillowQC1] FROM DISK = ''\\wh_reporting\incoming\LOG_WillowQC1_*.sqb'' WITH ERASEFILES = 168h, STANDBY = ''e:\2005-data\MSSQL$SQL2005\Backup\UNDO_WillowQC1.dat'', MOVETO = ''E:\2005-data\MSSQL$SQL2005\TRN_LOG_APPLIED''"', @errorCode OUT, @sqlerrorCode OUT;
IF (@errorCode >= 500) OR (@sqlerrorCode <> 0)
BEGIN
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @errorCode, @sqlerrorcode)
END
egay
0

Comments

2 comments

  • petey
    Yes, the MAILTO_ONERROR option is the one you need. E.g.

    EXECUTE master..sqlbackup N'-SQL "RESTORE LOG [WillowQC1] FROM DISK = ''\\wh_reporting\incoming\LOG_WillowQC1_*.sqb'' WITH ERASEFILES = 168h, STANDBY = ''e:\2005-data\MSSQL$SQL2005\Backup\UNDO_WillowQC1.dat'', MOVETO = ''E:\2005-data\MSSQL$SQL2005\TRN_LOG_APPLIED'', MAILTO_ONERROR = ''admin@yourco.com'' "', @errorCode OUT, @sqlerrorCode OUT;
    petey
    0
  • egay
    perfect.. thanks!
    egay
    0

Add comment

Please sign in to leave a comment.