PowerShell command to see the status from the SQL server tra

PowerShell script exchange

PowerShell command to see the status from the SQL server tra

Veeam Logoby Leahcim » Mon Feb 27, 2017 2:16 pm

Hi @all,
if anybody know how I can seee the status from the SQL transaction logs ? If the transaction logs fail, if they DB is potected and so one ?
I become enough informations about main backup job, but I can't find nothing about the child job which is in the background and run every one hour. If everyone have an idea how I can reach informations from the child job ?


mfg
Lehcim
Leahcim
Influencer
 
Posts: 12
Liked: never
Joined: Tue Feb 07, 2017 10:31 am
Full Name: Michael fenske

Re: PowerShell command to see the status from the SQL server

Veeam Logoby v.Eremin » Mon Feb 27, 2017 3:01 pm

May I ask you one question before we proceed to actual scripting? Do you happen to have Veeam ONE deployed? If so, isn't SQL Backup Job Historical Information report something that you're after?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: PowerShell command to see the status from the SQL server

Veeam Logoby Leahcim » Mon Feb 27, 2017 3:21 pm

Yes i have installed the Veeam One Reporter and I know the report for Microsoft SQL server. But I will create my own report, because in my mind the report from Veeam one is confusing and the second reason is that this report not include the Oracle server, that I need too.


BR
Leahcim
Leahcim
Influencer
 
Posts: 12
Liked: never
Joined: Tue Feb 07, 2017 10:31 am
Full Name: Michael fenske

Re: PowerShell command to see the status from the SQL server

Veeam Logoby v.Eremin » Mon Feb 27, 2017 4:30 pm

Example provided below should be a good starting point:

Code: Select all
asnp VeeamPSSnapin
#SQL
$SQLJob  = Get-VBRJob -Name "Name of your SQL Backup"
$SQLJob = $Job.FindChildSqlLogBackupJob()
$SQLJob.GetLastResult()
$SQLJob.GetLastState()

#Oracle
$OracleJob = Get-VBRJob -Name "Name of your Oracle backup Job"
$OracleJob = $OracleJob.FindChildOracleLogBackupJob()
$OracleJob.GetLastResult()
$OracleJob.GetLastState()


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: PowerShell command to see the status from the SQL server

Veeam Logoby Leahcim » Thu Jun 01, 2017 8:07 am

Hi, thank you for the script. I can see many entries about the Oracle job. But what I need if the information if the Database is protected or not like the report from Veeam Backup and replication:

http://fs5.directupload.net/images/170601/xponoo6y.jpg

With your script the informations for

$OracleJob.GetLastResult() are None
$OracleJob.GetLastState() are Working

but I can't find any information about the status. Any idea ?

Regards
Leahcim
Leahcim
Influencer
 
Posts: 12
Liked: never
Joined: Tue Feb 07, 2017 10:31 am
Full Name: Michael fenske

Re: PowerShell command to see the status from the SQL server

Veeam Logoby v.Eremin » Tue Jun 13, 2017 2:54 pm

You can try to load assembly (not an obvious way) and get the required data from there. The following script will find the latest completed (it is important) session and query its state:

Code: Select all
$Job = Get-VBRJob -name "Name of backup job"
$SQLJob = $Job.FindChildSqlLogBackupJob()
$Session = [Veeam.Backup.Core.CBackupSession]::GetByJob($SQLJob.Id) | where {$_.IsCompleted -eq $True} | sort creationtimeutc -Descending | select -Last 1
$Session.Result

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Google [Bot] and 7 guests