lordmilko / PrtgSensors

Miscellaneous sensors for PRTG Network Monitor
MIT License
9 stars 3 forks source link

Veeam sensor error: An exception occurred while trying to process backups: The term 'TapeJob::GetAll' 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. #2

Closed andriesgithub closed 2 years ago

andriesgithub commented 2 years ago

Hi,

I'm getting an error while reading Windows Agent Backup in Veeam. The following error im getting: An exception occurred while trying to process backups: The term 'TapeJob::GetAll' 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.

It's a separate backup job based on Windows Agent Backup

Any suggestions?

lordmilko commented 2 years ago

There's 2 issues here

  1. The UnknownJobTypeBackupHandler is using a function that no longer exists for checking whether a job is a tape job
  2. The job you've got does not have a type that is known to Get-VeeamBackupStatus.ps1, indicating possibly Veeam renamed it in a recent version

Are you potentially able to set a breakpoint on line 176 (switch($backup.JobType)) in the PowerShell ISE and then advise what the output of $backup.JobType is in the PowerShell console down the bottom? As noted in the README:

No attempt is made at backwards compatibility; when Veeam breaks the script, I fix it to make it work. No guarantee is made that such corrections will be uploaded to GitHib; this script is great, but be prepared to get your hands dirty when it breaks.

andriesgithub commented 2 years ago

Hi,

Thanks for your reply. I have set a breakpoint on line 176. The output: Entered Main Entered [VeeamBackupStatus]::GetStatus Entered [VeeamBackupStatus]::GetStatusInternal -Loading Veeam PSSnapIn -Connecting to Veeam Backup Server Entered [VeeamBackupStatus]::GetBackupsToProcess Entered [VeeamBackupStatus]::GetBackupHandler

I think Veeam renamd some codes. I dont which codes i have to change in the script :)

lordmilko commented 2 years ago

Are you able to confirm what version of Veeam + Veeam Agent for Windows you're running? I tested this with Veeam Backup & Replication 11.0.0.837 against a Veeam Agent for Windows job and it worked as expected

Damaskar commented 2 years ago

Hello,

I have same problem when im trying to monitor Linux agent backup job. Setting breakpoint on line 176 give me same results as andriesgithub.

Versions: BRv11 - 11.0.1.1261 Linux Agent - 5.0.2.4567

lordmilko commented 2 years ago

This script has not been tested with Veeam Agent for Linux, this could be the source of the issue

Can you try opening a Veeam PowerShell prompt (via the Veeam Console on your VBR server) and then doing

[Veeam.Backup.Core.CBackupJob]::Get("My backup job")

Where My backup job is the name of your backup job. This should return information about your backup job. What is the value of the JobType property in the output that is emitted?

Damaskar commented 2 years ago

Thank you for such fast reply.

Here is JobType: Linux Agent Policy

lordmilko commented 2 years ago

Thanks @Damaskar,

Does the JobType actually have spaces in it? i.e. is the value LinuxAgentPolicy or Linux Agent Policy?

On line 178 of the script is the dispatcher for most backup types. Can you add the value from JobType exactly as it is written to this list and then try and run the script again?

{$_ -in "Backup","Replica","BackupSync","EndpointBackup"} { $handler = [BackupHandler]::new($backup, $this.jobName) }

so if the JobType is foo line 178 would become

{$_ -in "Backup","Replica","BackupSync","EndpointBackup","foo"} { $handler = [BackupHandler]::new($backup, $this.jobName) }
Damaskar commented 2 years ago

JobType according to veeam powershell is exactly Linux Agent Policy with spaces. I tried to put both variants LinuxAgentPolicy and Linux Agent Policy in 178 line, still getting same result:

An exception occurred while trying to process backups: The term 'TapeJob::GetAll' 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.

lordmilko commented 2 years ago

My recommendation would be to put a breakpoint on line 59 and simply step through the code until you get to line 176

Then you can see what JobType it's switching on

lordmilko commented 2 years ago

From a quick look at my Veeam server, I definitely don't think the JobType you got is right

JobType is a value of type Veeam.Backup.Model.EDbJobType which is an enum, meaning there's no spaces

Maybe try the following (enter the name of your backup job)

[Veeam.Backup.Core.CBackupJob]::Get("Backup Job Damaskar-PC").JobType
lordmilko commented 2 years ago

It looks like the type is EpAgentPolicy

Are you able to try adding that to the list?

Damaskar commented 2 years ago

Huh

[Veeam.Backup.Core.CBackupJob]::Get("Backup Job Damaskar-PC").JobType

Gave me EpAgentPolicy instead of Linux Agent Policy I guess [Veeam.Backup.Core.CBackupJob]::Get("My backup job") showing something else in Job Type for some reason. I put EpAgentPolicy in 178 line and everything works now Thank you very much

lordmilko commented 2 years ago

@andriesgithub,

Are you able to advise what the output of [Veeam.Backup.Core.CBackupJob]::Get("My backup job").JobType is in a Veeam PowerShell prompt for you?

Alternatively, if you download the latest version of the script (1.3.17) and try and re-run it it should no longer crash before telling you the name of the JobType it didn't know how to handle