PowerShell Script to show running Veeam jobs at point or period of time

  • 20 October 2020
  • 5 comments
  • 3189 views

Userlevel 7
Badge +13

Recently I had to troubleshoot a Veeam Backup & Replication (B&R) problem. There the question popped up which are the running Veeam jobs at point or period of time. The GUI is not a big help to answer this question. Therefore I wrote a small script that show these jobs.

The following PowerShell script snippet is quite simple. First, start- (tStart) and end-date/time (tEnd) are asked for input. The following query selects all running Veeam jobs at point or period of time that matches input dates.

# Ask for start- and end-date and time
Write-Host "Enter date in format " ($(get-date).ToString("dd.MM.yyyy HH:mm"))
$tStart = Read-Host "Enter start-time (Enter for now)"
$tEnd = Read-Host "Enter end-time (Enter for equal to start-time)"

if ($tStart -eq '') {$tStart = get-date -Format "dd.MM.yyyy HH:mm"}
if ($tEnd -eq '') {$tEnd = $tStart}

# Check input data
try {$tStart = [DateTime]::Parse($tStart)}
catch {Write-Host "start-time wrong input"; continue}
try {$tEnd = [DateTime]::Parse($tEnd)}
catch {Write-Host "end-time wrong input"; continue}
if ($tStart -gt $tEnd) {Write-Host "start-time after end-time"}

# Load Veeam PowerShell Plugin
Add-PSSnapin VeeamPSSnapIn
# Connect to local Veeam Server
Connect-VBRServer -Server localhost

# Query jobs
Get-VBRBackupSession | Where-Object {($_.CreationTime -le $tStart -and ($_.EndTime -ge $tStart -or $_.EndTime -eq [DateTime]"1.1.1900")) `
-or ($_.CreationTime -ge $tStart -and $_.CreationTime -le $tEnd)} `
| select JobName, CreationTime, EndTime | Sort-Object Jobname | ft -AutoSize

# Disconnect from Veeam Server
Disconnect-VBRServer

Script Notes

  • Script asks for date and time. You can just input date, time will be 00:00 than.
  • To show all jobs running right now, just input blank start- and end-date.
  • Command Add-PSSnapin VeeamPSSnapIn loads Veeam PowerShell Plugin. This is available at Veeam B&R server.
  • The connection to Veeam B&R is established by running Connect-VBRServer. When running this script at a Veeam B&R Server, connect to localhost like here. To start this query at a Veeam B&R Server, you can run it as it is.
  • Script show these types of jobs:
    • Backup jobs
    • Replication jobs
    • File copy jobs
    • Backup copy jobs.
  • If you use a different date/time format, take care it works for you. When not, change format options that way it fits to your format.
  • If you want to doing further processing of the result of this script, remove | Format-Table -AutoSizeat the end.

Notes

  • Script to show last successful backup and how long they are ago, you can find here.
  • Veeam PowerShell Reference you can find here.


5 comments

Userlevel 2

Awesome - thanks for that!

 

Maybe you have a solution for another problem we have:
When scheduling a new backup job, SAP Hana Plugin or Oracle Rman full backup it would great to know when the B&R Server has time for it :-)


As a first step maybe a script to get the start- and endtime for all backup jobs, SAP Hana and Oracle RMAN full backups (especially the Hana and Oracle full backups are hard to find between all log backups via the Veeam GUI.

Best solution would be a  “time beam” graphic where you could see all time slots with no or only a few jobs running. Or is there already a InfluxDB / Grafana Project doing something like that?
 

Userlevel 7
Badge +13

Awesome - thanks for that!

 

Maybe you have a solution for another problem we have:
When scheduling a new backup job, SAP Hana Plugin or Oracle Rman full backup it would great to know when the B&R Server has time for it :-)


As a first step maybe a script to get the start- and endtime for all backup jobs, SAP Hana and Oracle RMAN full backups (especially the Hana and Oracle full backups are hard to find between all log backups via the Veeam GUI.

Best solution would be a  “time beam” graphic where you could see all time slots with no or only a few jobs running. Or is there already a InfluxDB / Grafana Project doing something like that?
 

I agree! Would be great to see job history on a graphical timeline. I am sorry, neither I don’t have a solution for that nor I know one. But if you find one, let us know!

Userlevel 6
Badge +1

Another great script man! This is some seriously cool stuff. I will let you know how it goes in my setup.

Userlevel 7
Badge +13

[update]

I just remembered, I made a picture that could help in understanding the script.

It shows the possible situations job-times can have in relation to selected interval. Hope it helps.

Can you help on the IBM DB2 Backup in veeam backup, since there is no IBM DB2 plugin in veeam v12, looking for a shell script connecting to DB2 database & initiate backup from veeam backup v12.

Comment