PowerShell script exchange
Post Reply
johannesk
Expert
Posts: 148
Liked: 32 times
Joined: Jan 19, 2016 1:28 pm
Full Name: Jóhannes Karl Karlsson
Contact:

disable-vbrjob - Check backup Transaction log sessions

Post by johannesk »

Hi,

We are working on automating windows updates on our VBR servers. To do that we want to disable all the jobs before we stop the backup service and reboot the server.

It's easy to disable all the jobs, but is there a way to see when the transaction log backups have finished afther a job has been disabled? We want to make sure there are no jobs running like 'SQLjobname SQL server transaction log backup' as can bee seen in the 'running view' in the GUI.

Regards,
Jóhannes
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: disable-vbrjob - Check backup Transaction log sessions

Post by oleg.feoktistov » 1 person likes this post

Hi Johannes,

No official way to do that, but you can try it through these .NET methods:

Code: Select all


# Get job with enabled transaction log backup 
$job = Get-VBRJob -Name 'Backup Job Name'
$jobType = [Veeam.Backup.Model.EDbJobType]::SqlLogBackup

# Get transaction log backup job by parent job and type
$logBackupJob = [Veeam.Backup.Core.CLogShippingJobManager]::FindChildLogJob($job.Id, $jobType)

# Get all transaction log sessions for the given log backup job
$logSessions = [Veeam.Backup.Core.CBackupSession]::GetByJob($logBackupJob.Id)
All the info for job count, state, creation time etc. should be in $logSessions variable then.

Best regards,
Oleg
johannesk
Expert
Posts: 148
Liked: 32 times
Joined: Jan 19, 2016 1:28 pm
Full Name: Jóhannes Karl Karlsson
Contact:

Re: disable-vbrjob - Check backup Transaction log sessions

Post by johannesk »

Thanks Oleg,

this is just what we need. There is one typo in the script. I changed the last line to use the variable $logBackupJob.Id instead of $logBackup.Id so it will use the variable from the previous line.

Regards,
Jóhannes
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: disable-vbrjob - Check backup Transaction log sessions

Post by oleg.feoktistov » 1 person likes this post

Hi Johannes,

Thanks for pointing that out. I fixed it in the script above for the convenience of other people, who might visit this topic.

Best regards,
Oleg
johannesk
Expert
Posts: 148
Liked: 32 times
Joined: Jan 19, 2016 1:28 pm
Full Name: Jóhannes Karl Karlsson
Contact:

Re: disable-vbrjob - Check backup Transaction log sessions

Post by johannesk »

Just a bit of follow up

the script assignes 'SqlLogBackup' parameter to use as a filter:
$jobType = [Veeam.Backup.Model.EDbJobType]::SqlLogBackup

I was trying to see what other jobtype parameters are possible, but I don't see it.

As a novice powershell user I ask, how can I list up available parameters for this property Veeam.Backup.Model.EDbJobType?
I know about | get-member but that does now show me what I need.

I might want to filter on different sessions such as restore and tape sessions.

Regards,
Jóhannes
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: disable-vbrjob - Check backup Transaction log sessions

Post by oleg.feoktistov » 1 person likes this post

Hi Jóhannes,

You can easily list enum values with this method :

Code: Select all

$jobTypes = [Veeam.Backup.Model.EDbJobType]
$jobTypes.GetEnumValues()
Or follow the hints from PowerShell IntelliSense when typing [Veeam.Backup.Model.EDbJobType]:: in Powershell ISE.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests