Monitor Veeam Backup Jobs with PRTG

Last weekend I was playing around with Paessler PRTG Network Monitor and asked myself how hard can it be to monitor a Veeam Backup Job status. Well this proved to be a bit more difficult than I thought… The reason why is because I also need to see the date of the Backup Job somewhere in the message of the sensor, otherwise you can’t see when the last time was that the backup job has run. And this part was a little bit tricky to get to work, but after some PowerShell voodoo I got the result I was looking for :

 
PRTG-Veeam-Status

 
And when there is a Backup Job warning the status changes and the Backup Job date remains visible :

 
PRTG-Veeam-StatusWarning

 

Prerequisites :

  • Veeam Backup and Replication PowerShell installed on the Veeam Backup Server.
  • Veeam Backup server is already being monitored.
  • Windows Remote Management enabled on the Veeam Backup Server.
  • PRTG probe service account has access to the Veeam Backup Server.

     

    PowerShell Script with DB on the same host as the Veeam Backup Server :

    Save the following script to the file backup_status.ps1 in the directory : C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE

     

    PowerShell Script with DB on a different host than the Veeam Backup Server :

    Laurens (see comments below) encountered some issues when he was trying to get this sensor to work. It turns out that this was because his Veeam Backup DB wasn’t running on the backup server. But we got it to work with some additional credential / delegation settings :

    On the Veeam & SQL server run :

    On the PRTG server run :

    Be sure to run the following command under the PRTG Probe Service Account!

    The save the following script to the file backup_status.ps1 in the directory : C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE

     

    PRTG Settings

    Now it is time to add a new sensor to the Veeam Backup Server in PRTG. Open the (already added) Veeam Backup Server device in PRTG and click “add sensor”. Search for “EXE/Script” and click on the matching sensor below “Matching Sensor Types”.

     
    PRTG-Veeam-AddSensor

    Fill in the following fields :

    Sensor Name : Enter a name for the Sensor for example Veeam Backup Job
    EXE/Script : Select backup_status.ps1 from the drop-down list
    Parameters : Enter a Veeam Backup Job name you would like to monitor between two quotes for example “Backup Job”

    And select continue

     
    PRTG-Veeam-ConfigureSensor

    That’s all! Add the sensor to one of your PRTG maps and enjoy your new way of monitoring your Veeam Backups instead of going through your Veeam Report emails 🙂

    PRTG-Veeam-MapOK

  • Marco van Baggum

    Marco van Baggum

    Marco works as a Staff Consulting Architect at VMware. Want to learn more about Marco? Check out Marco's About page.

    58 thoughts on “Monitor Veeam Backup Jobs with PRTG

    1. Nice work m8! Testing it now.
      The fillinyourveeambackupservername is the backup server dns name? does it look into the database? if so should that name be the sql server which has the veeam database?

      1. You can fill in the FQDN of the Veeam Backup Server, because this uses the Veeam Powershell API and not a direct connection to the DB server. But be aware that the Veeam Probe Service Account requires access to Veeam!

        And thanks! Hope to drop by soon for some coffee 🙂

        1. Jo Dude! coffee is always ready here! You know the way:)

          I’m getting an error while having all pre requisites.
          Added probe service account as veeam administrator, that enough?

          Response not wellformed: “(Microsoft SQL server hosting the configuration database is currently unavailable. Possible reasons are heavy load, netw orking issue, server reboot, or hot backup. Please wait, and try again later. Error information: SQL server is not available + CategoryInfo : NotSpecified: (:) [Get-VBRJob], CSqlException + FullyQualifiedErrorId : Veeam.Backup.Common.CSqlException,Veeam.Backup.PowerShell.Command.GetVBRJob + PSComputerName : backup01 Microsoft SQL server hosting the configuration database is currently unavailable. Possible reasons are heavy load, netw orking issue, server reboot, or hot backup. Please wait, and try again later. Error information: SQL server is not available + CategoryInfo : NotSpecified: (:) [Get-VBRBackupSession], CSqlException + FullyQualifiedErrorId : Veeam.Backup.Common.CSqlException,Veeam.Backup.PowerShell.Command.GetVBRBackupSession + PSComputerName : backup01 )” (code: PE132)

    2. Hello Marco,

      Thank you for this great article, it’s definitaly a big improvement over the SQL querries we are using…

      I think we’ve ran into a little problem here, though. When running the script from my remote probe, as well as on the machine itself, the following error occurs:

      “Cannot validate argument on parameter ‘Name’. The argument is null or empty. Pr
      ovide an argument that is not null or empty, and then try the command again.
      + CategoryInfo : InvalidData: (:) [Get-VBRJob], ParameterBindingV
      alidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.Po
      werShell.Command.GetVBRJob
      + PSComputerName : Veeam01”

      I’ve ran the commands one by one (without the silent continues) to see where it goes wrong, and the error is related to this part:
      $Job = Get-VBRJob -Name $BackupJobName -WarningAction SilentlyContinue

      The variable is empty, and it doesn’t like that. We’ve been trying to figure it out, but no results so far. Could you please advice?

      Best regards,
      Yarno

        1. Hi Marco,

          That was indeed the problem. Completely overlooked it, haha. Thank you for your swift reply.

          Something to keep in mind: creating this sensor for a job in “failed” state might not be a good idea.

          The sensor will return the system error code for an EXE sensor (PE022), along with the date which is normally returned. Further, the Status channel will not be created. This can be a bit of an issue when you want to run reports on the results right away. This can of course be corrected later on, as jobs are running succesfully again.

          Thanks again,
          Yarno

    3. Hi Marco,

      My PRTG server is not a domain member and I get an error when running the script against the Veeam server, which is a domain member. I tried to use the scripts for an off server SQL instance, but get an error when running the command on the PRTG server saying my PRTG server can’t connect to the Veeam server. I’m guessing it’s a permission issue.

      Is there anyway to pass alternate credentials?

      Thanks,
      Chris

      1. Hi Chris,

        What is the error that you received? Maybe I can help you, but from past “battles” with ps remoting between domain and non-domain joined server it can be a kind of pain in the ***.

        Marco

    4. This is a great setup… not sure where I am going wrong. We are still running Veeam v7. I have a small setup that is using SQL Express on the Veeam server.

      When running the PS manually and passing the arguments as outlined in the script, I get the expected response “0:13-04-2015 12:04”, however, when trying to run it from our PRTG install, I get the following error “Response not wellformed: “(Microsoft SQL server hosting the configuration database is currently unavailable. ”

      Is there something I am missing?

      1. Hi Ryan,

        Does the PRTG service account (which runs the PS script) have access to Veeam and the SQL service?
        And when you run the PS script manually, are you logged in as the PRTG service account or as another user?

        Marco

    5. Hi Marco,
      how did you get the 64bit Veeam Powershell Snapins running with the 32bit Powershell? PRTG calls the 32bit engine and the cmdlets cannot be found…. Or are there 32bit cmdlets?
      Kind regards Philipp

      1. Hi Philipp,

        Unfortunately there is no 32bit Veeam PSSnapin available, therefore I’m using PS remoting so I’m able to run 64bit commands and use the 64bit Veeam PSSnapin from a 32bit PS session.

        Marco

    6. Hi Marco,

      running the ps1 locally on the prg server works fine, when I add the sensor as descripted it fails with the error;
      Response not wellformed: “([veeam01] Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_T roubleshooting Help topic.
      + CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:Re moteRunspace) [], PSRemotingTransportException + FullyQualifiedErrorId : PSSessionOpenFailed Invoke-Command : Cannot validate argument on parameter ‘Session’. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\backup_status .ps1:9 char:38 + $PRTGstring = Invoke-Command -Session <<<< $PSSession -ScriptBlock { + CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBind ingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power Shell.Commands.InvokeCommandCommand )" (code: PE132)

      1. Hi Marco,

        I saw that error before and that was because of the PS Execution Policy was still on “Restricted”, can you check the setting under the PRTG Service Account? Just log in with the PRTG Service Account, open PS, and run Get-ExecutionPolicy. It has to be set on “RemoteSigned” or “Unrestricted”, if you need to change it just use “Set-ExecutionPolicy Unrestricted” (or RemoteSigned). Let me know!

        Marco

        1. what is prtg service account? if I run it from powershell script on prtg server works properly, but does not work executed by the web of prtg.

          Fabio

    7. Hello,
      I’ve allways the following failure when i start the script:

      Die Benennung “Get-VBRJob” wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die
      Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
      + CategoryInfo : ObjectNotFound: (Get-VBRJob:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName : Server01

      Die Benennung “Get-VBRBackupSession” wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie
      die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
      + CategoryInfo : ObjectNotFound: (Get-VBRBackupSession:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName : Server01

      What’s wrong or missing?

    8. Hi,
      I have installed Veeam Powershell, but still get this:
      Add-PSSnapin : The Windows PowerShell snap-in ‘VeeamPSSnapIn’ is not installed on this computer.
      At line:1 char:1
      + Add-PSSnapin -Name VeeamPSSnapIn
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidArgument: (VeeamPSSnapIn:String) [Add-PSSnapin], PSArgumentException
      + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

      We are running Veeam on a Win 8. Is that an issue?

      1. Hi Robert,

        I spoke with some Veeam support guys today and they advice the following :

        Reboot the Server
        Reinstall Veeam B&R u2
        Reboot the Servers
        Reinstalling KB1489
        Reboot the Server
        Start the PowerShell Modules from the menu of Veeam Backup & Replication

        Let me know if this works.

        Marco

    9. I would love to get this to work but I keep getting a error for ‘No Channel” and the message execution of scripts is disabled on this system.
      This is running via a remote probe. I have set the execution policy on the backup server and the probe server to be unrestricted. The script is running on the probe device.

      What am I missing?

        1. Marco,
          I suppose that is the problem. I don’t have the powershell snapins on the probe server because I don’t have Veeam running on the probe server. Trying to install the ps snapins alone doesn’t seem possible. I was hoping to run the probe and Veeam on separate servers. Is that possible? Are the ps snapins required to be on the probe server?
          I suppose I could a probe on the backup server.

          1. Hi Glen,

            Yes the PS Snapins are required.
            Maybe if possible you could install an instance of Veeam on the probe server and disable the services? This way you can use the PS Snapins.

            Marco

    10. Hi, i have implemented the script on v8. it functions good in command-line mode, for example it returns “0:04-12-2015 08:00”
      Running as EXE Sensor on the PRTG it returns on the message field “UnauthorizedAccess”.
      may you help me , thanks.
      AB

        1. I get the same message when adding the probe. I have added the same user to the probe service in the service console as the one i have the in the Veeam Server. When i run the script in powershell it works fine. Can you please assist or clarify exactly where i have to give access to?

          Thanks

        2. I have given access to the Probe service in the service console to the same admin account running the Veeam service but i keep getting “UnauthorizedAccess”. If i run the script from the server it returns the result correctly. Any tips?

    11. I am trying to get it to work but getting an unlogic errorcode. Our situation, the PRTG server is a standalone server running in its own subnet but has access to the veaam backup server. The Veeam backup server runs in a Windows domain on server 2012 R2.
      Actions already done, make DNS name of veeambackup server resolveable for the PRTG server. Enabled Powershell execution policy for both servers. Enabled remote powershell and added the prtg server as trusted servername.

      The error is :

      Response not wellformed: “(File D:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\backup_stat us.ps1 cannot be loaded because the execution of scripts is disabled on this sy stem. Please see “get-help about_signing” for more details. At line:1 char:157 + if ($PSVersionTable.PSVersion -ge (new-object ‘Version’ 5,0)) { Import-Module Microsoft.PowerShell.Management; Import-Module Microsoft.PowerShell.Utility};& <<<< 'd:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\backup_st atus.ps1' 'Backup Job DC Servers DC-03'; exit $LASTEXITCODE + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException )" (code: PE132)

      1. Hi Henk,

        Is it possible that the Execution-Policy is not been set to “Unrestricted” or “RemoteSigned” yet?
        Please from elevated and un-elevated PowerShell run the following command : Set-ExecutionPolicy Unrestricted
        And try again! Good luck!

        Marco

    12. Hi Marco,

      Yeah I already did that, but does not affect the error. I think it is bumping into something else I will see if I can fix it.

      thanks!
      Henk

    13. Funny running into this post 😉 still using some of the things you tought me, as you can see 🙂 thanks for this, i was just looking for the best way next to monitoring my backup results by checking mail. This is way better!

    14. Hi, I have the PRTG Probe on the same server as Veeam Backup and therefore I can not build remote session, you have a solution to that? How should the script be adapted?

    15. Hi,

      I followed up on the first script, but can’t figure out why I get this error. (could it be because veeam is running on windows 7?:

      Antwoord niet goed geformateerd: “(New-PSSession : [VEEAM8.*fqdnhere*l] Connecting to remote server VEEAM8.*fqdnhere* failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: “winrm quickconfig”. For more information, see the about_Remote_Troubleshooting Help topic. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\backup_status.ps1:6 char:14 + $PSSession = New-PSSession -ComputerName $VeeamBackupServer + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:Re moteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed Invoke-Command : Cannot validate argument on parameter ‘Session’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\backup_status.ps1:9 char:39 + $PRTGstring = Invoke-Command -Session $PSSession -ScriptBlock { + ~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBind ingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power Shell.Commands.InvokeCommandCommand )” (code: PE132)

    16. Any help would be appreciated.
      The name of my backup server is “veeam”, but when I run .\backup_status.ps1 “one of my job names” I get the following error:
      PS C:\Program files (x86)\PRTG Network Monitor\Custom Sensors\EXE> .\backup_status.ps1 “2012ut”
      The term ‘Get-VBRJob’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
      spelling of the name, or if a path was included, verify that the path is correct and try again.
      + CategoryInfo : ObjectNotFound: (Get-VBRJob:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName : veeam

      The term ‘Get-VBRBackupSession’ is not recognized as the name of a cmdlet, function, script file, or operable program.
      Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
      + CategoryInfo : ObjectNotFound: (Get-VBRBackupSession:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      + PSComputerName : veeam

      1. Looks like I need to open a case with VEEAM.
        Even after doing these steps:
        I spoke with some Veeam support guys today and they advice the following :

        Reboot the Server
        Reinstall Veeam B&R u2
        Reboot the Servers
        Reinstalling KB1489
        Reboot the Server
        Start the PowerShell Modules from the menu of Veeam Backup & Replication

        The VEEAM PowerShell Modules are not being installed. 🙁

        1. Just got off the phone with VEEAM support services.
          The have a known problem getting the powershell services for VEEAM installed and they ran a script on my VEEAM server to fix that issue. I will be testing the result later today and if it works I will let people know.

          I have also requested VEEAM to make the script available to the public as a KB article or some other way.

    17. Hello,

      i have some comment ( i used the script for veeam 9)

      1) You dont need to save the password in a seperat file:
      Set the PRTG Sensor to “Set placeholders as environment values” and use following code:
      $Username = “$($env:prtg_windowsdomain)”+”\” +”$($env:prtg_windowsuser)”
      $password = $env:prtg_windowspassword | ConvertTo-SecureString -AsPlainText -Force
      then the script will use Credentials from PRTG (Set in the Windows Account Settings)

      2) Instead of “Enable-WSManCredSSP Server” and so on i used “winrm quickconfig” on Command Screen of the Veeam Backup Server.

      3) you can only Backup to Disk with this Job, Backup to Tape didn’t work

      Anyway thanks for the script. so i now got a clue how to remote execute the the script and get the results to my prtg server.

      Actually i try to work on a multi channel sensor to monitor all active jobs in one Sensor of prtg (exexml sensor).

      best regards
      Heiko

    18. I only get the script to work when I fill in the actual job name after the “$BackupJobName” variable.
      If i leave the “$args[0]” and run the script manually, i get this error:

      Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
      + CategoryInfo : InvalidData: (:) [Get-VBRJob], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.GetVBRJob
      + PSComputerName : %servername%

    19. To also be able to check backupcopy job status, modify the script:

      Replace line 16 + 17 with:

      If($job.JobType -eq “Backup”){
      #Get the information from the latest Backup Job
      $BackupSession = Get-VBRBackupSession -WarningAction SilentlyContinue | ?{$_.JobId -eq $Job.Id} | Sort -Descending -Property “CreationTime” | Select -First 1
      }
      ElseIf($job.JobType -eq “BackupSync”){
      $BackupSession = Get-VBRBackupSession -WarningAction SilentlyContinue | ?{$_.JobId -eq $Job.Id} | Sort -Descending -Property “CreationTime” | Select -first 2 | Select -Last 1
      }

    20. I’m trying this script out but i keep getting execution of scripts disabled, but i already set the executionpolicy to remotesigned….

      Do you guys have a solution?

      PRTG and Veeam are on different servers…

      1. Hi Jestar,

        You will have to set that on both servers AND be aware that powershell can be run as administrator and as a normal account! So please do check if you have set the correct setting on the correct user.

        Marco

    21. Hi

      I’m very new to scripting so there may be a simple answer. I’d love to get this script working in our Veeam/PRTG environment, but having issues. We are using Veeam v8, and VSSSnapin is installed. Whenever I run the script locally (Veeam and DB on the same server), from within Veeam Powershell by entering the .\veeam_backup_status “jobname” I get the following errors. If I run Get-VBR Job from the same powershell window it accepts the command. Any ideas?

      The term ‘Get-VBRJob’ is not recognized as the name of a cmdlet, function, scri
      pt file, or operable program. Check the spelling of the name, or if a path was
      included, verify that the path is correct and try again.
      + CategoryInfo : ObjectNotFound: (Get-VBRJob:String) [], CommandN
      otFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
      The term ‘Get-VBRBackupSession’ is not recognized as the name of a cmdlet, func
      tion, script file, or operable program. Check the spelling of the name, or if a
      path was included, verify that the path is correct and try again.
      + CategoryInfo : ObjectNotFound: (Get-VBRBackupSession:String) []
      , CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

    22. Firstly one of the best script out here for the Veeam/ PRTG integration displaying the date is a real plus.

      My problem is we are service provider and we have the Main PRTG at our head office and various probes at our customers.

      All with there own install of Veeam.

      How can i get this to connect to all of our customers ? Can this be ran from the remote probe some how?

      Thanks

      Adam

      1. Hi Adam,

        Surely this should work but it needs some customization of the execution of the script.
        Contact me through one of the social media channels and maybe we can work something out.

        Marco

    23. Your first script isn’t updated with the “None” case, so PRTG will send an error. 😉

      I prefer checking only finished backups, and ignoring running ones.
      If people want it this way, just replace ?{$_.JobId -eq $Job.Id} with ?{$_.JobId -eq $Job.Id -and $_.Result -ne “None”}

      Florian

    24. Hi Marco,

      Thank you very much for this.

      In case I am missing the obvious, is there a way this script can output the error message along with the status? Reason being we are wanting to set up a task that restarts VSS when a particular backup fails with a particular error message.

      Thanks,
      Kane

    25. I’m receiving the following error: “The term ‘Get-VBRJob’ is not recognized as the name of a cmdlet”. This while the Veeam PS module is installed and able to run the command on the local veeam server.

      This issue is occurring on veeam > version 8. Localmachine had rights to start powershell scripts. Does this has something to do with the .NET version installed? Both 3.5 and 4.x are installed (on remote machine). Anyone else experience this issue?

    26. Hi
      Thanks, you for this useful Tools.

      Working great on 2012R2 Server, on 2016 we receive an Error, I can’f igure out way. Can you help us?
      Error:
      Invoke-Command : Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
      In C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\backup_status.ps1:7 Zeichen:15
      + $PRTGstring = Invoke-Command -Session $PSSession -ScriptBlock {
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidArgument: (PopRunspace:String) [Invoke-Command], NullReferenceException
      + FullyQualifiedErrorId : RemoteHostCallFailed,Microsoft.PowerShell.Commands.InvokeCommandCommand

      Thanks
      Ephi

    27. Hello Marco van Baggum is there a way to contact you ? Maybe you can have a look on my setup i will pay for this i cant get it woirking 🙁

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.