E14– Windows Server Backup on DAG–Part3–Notify DB Status before process WSB

 

1.

echo off

For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)
For /f "tokens=1-2 delims=: " %%a in ('time /t') do (set time=%%a:%%b)

rem echo The date is %date%
rem echo The time is %time%

Rem ==================================
PowerShell.exe -command ". C:\Batch\WSB\PS_RedistributeActiveDatabase_before-WSB.ps1"

Rem ==================================
Cscript C:\Batch\WSB\DB_Active_Notify.vbs

Rem ==================================
del  "C:\Batch\WSB\DB_Activation_Log\DB_Activation.txt"

Timeout /T 100

Rem ==================================
Rem ==================================
set backuplog="c:\batch\WSB\BackupLog\"%computername%-WSB.txt""

echo. Start:%date%  %time%  >> %backuplog%
echo. ================================== >> %backuplog%

Rem ==================================

rem pause
wbadmin start backup  -backupTarget:B: -include:P:,S:,T:,U:,V:,W:  -vssFull -quiet >> %backuplog%

Rem ==================================
echo. ================================== >> %backuplog%

For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)
For /f "tokens=1-2 delims=: " %%a in ('time /t') do (set time=%%a:%%b)

echo. Start:%date%  %time%  >> %backuplog%
echo. ================================== >> %backuplog%

Rem ==================================
cscript C:\Batch\WSB\Backupnotify.vbs

Rem ==================================
copy "c:\batch\WSB\BackupLog\"%computername%-WSB.txt"" "c:\batch\WSB\BackupLog\"%computername%-WSB_%date%.txt"" /Y
del  "c:\batch\WSB\BackupLog\"%computername%-WSB.txt""

 

2. Cscript C:\Batch\WSB\DB_Active_Notify.vbs

Rem ==================================
Cscript C:\Batch\WSB\DB_Active_Notify.vbs

 


3. Location of DB_Active_Notify.vbs
image

 

4. DB_Active_Notify.vbs

On Error Resume Next

Set net = CreateObject("WScript.Network")
sCompName = net.Computername


Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("C:\Batch\WSB\DB_Activation_Log\DB_Activation.txt", ForReading, True, -1)

strText = objTextFile.ReadAll
Wscript.Echo strText

m=Month(Now)
d=Day(Now)
s=Second(Now)

If (m<10) Then
    m="0" & m
End If
If (d<10) Then
    d="0" & d
End If

sDate = Y & M & D


Set email = CreateObject("CDO.Message")'
email.From = ""&sCompName&"@MSFT.com"
email.To = "Johnny.Yao@MSFT.Com"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.82.131.80"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
email.Configuration.Fields.Update
email.Subject = ""&sDate&" -  "&sCompName&"_DB Activation Log"
email.TextBody = strText
email.AddAttachment "C:\Batch\WSB\DB_Activation_Log\DB_Activation.txt"
email.Send
Set email = nothing

objTextFile.Close

 


5. DB Activation Log
image



6.

del "C:\Batch\WSB\DB_Activation_Log\DB_Activation.txt"

 

7.

Timeout /T 100

Comments

Popular posts from this blog

E15 CU3–Update Failed–AD replicated Exceeded the tombstone lifetime.

202301 - Exchange onpreme - PowerShell Serialization Payload Signing

Ticket: RemoteAPP certificate revocation check error