Link to home
Start Free TrialLog in
Avatar of CCG3
CCG3Flag for United States of America

asked on

Change bat file to email failures

Hello Everyone, I run a batch file that backs up a local copy of my SharePoint Server and then copies that backup file to a NAS server where I later back it up to tape or disk. I was wondering if based on the following lines that I have in my script if there was some way to determane if it failed and if so can I send myself an email that if failed.

Here is what I run each evening to get my backup....

cd %programfiles%\Common Files\Microsoft Shared\web server extensions\12\BIN


stsadm.exe -o backup -url https://SHAREPOINTSITE -filename C:\SharePointBak\SPSiteBak.dat -overwrite


xcopy "C:\SharePointBak" "\\NAS DATA SERVER\SharePoint Backup" /e /y
SOLUTION
Avatar of Grasty86
Grasty86
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Darren Collins
Apparently stsadm.exe returns 0 when successful and -1 (or non-zero) when it fails [1].

I would do something like this:
cd %programfiles%\Common Files\Microsoft Shared\web server extensions\12\BIN


stsadm.exe -o backup -url https://SHAREPOINTSITE -filename C:\SharePointBak\SPSiteBak.dat -overwrite
If %ERRORLEVEL% NEQ 0 Goto EmailFail

xcopy "C:\SharePointBak" "\\NAS DATA SERVER\SharePoint Backup" /e /y

Goto End

:EmailFail
REM Do the emaily-bit here

:End
REM End Of Script

Open in new window


Hope this helps,
Daz.

[1] http://blogs.msdn.com/b/markarend/archive/2007/11/08/scripting-stsadm-commands.aspx
That would only notify you if the backup failed, not if the backup succeeded and the copy failed.

Maybe you could modify that so that there is 2 spots to send an email? One to send an email saying the Backup Failed, and another that said the copy failed but the backup succeeded.
Avatar of CCG3

ASKER

That is a great suggestion Grasty! How would i do that?

I created a vbs to send an email and I am calling that vbs to send an email if it fails to backup. How would I determine if the copy fails and then send an email if it does?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree, Daz's should work great for you (once you put in your calls for the vbs script you have of course.
Avatar of CCG3

ASKER

Thanks guys! I was able to set this up and test it yesterday and I ran it live last night. Everything seems to be fine. Thanks for your help!!