Hello, I refer here to the entry from veeam-one-f28/custom-report-for-the-las ... ml#p474552
What could be a PowerShell script that generates such a report?
Short round up:
Hello together,
I would like to create a special report from Veeam ONE or create it via PowerShell directly on the backup server.
I have already tried to create such a report in Veeam ONE but there is always too much information. The report should contain this:
- Pure number of existing restore points per job
- How many backups were successful in the last 30 days
- How many backups were aborted or failed
Maybe this is only possible with PowerShell.
Kind regards
Florian
-
- Influencer
- Posts: 12
- Liked: never
- Joined: Apr 16, 2020 3:38 pm
- Full Name: Florian Reichelt
- Contact:
-
- Veeam Software
- Posts: 2038
- Liked: 501 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Custom Report for the last 30 days
Hi Florian,
I punched out the framework for you on this a bit on Virtualized Backups (VMware/HyperV) but I'm not sure on the desired final format, so you might need to do some customizing. Similarly, likely this won't work for Nutanix/Agents based backups, that will require a bit of extra code. Tape Jobs also are "special", but not sure if your clients are needing this.
This will populate two arrays:
$ReportDetails: Shows the name of the Job, the Restorepoints for each object in the job with their counts, and also reports on failed sessions.
$OrphanedBackups: Since I use a .NET method here and we can't use -ErrorAction or Out-Null, we try/catch on the GetJob() method and if it fails, we assume that there are backups without an associated job.
I chose to parse based on Get-VBRBackup as it's easier to get at Restorepoint data with this (fewer calls since we already have the backups and we can feed the CBackup object into Get-VBRRestorePoints). From there, we use GetJob() method on the CBackup Object to find its owner job, and then we process sessions from that job. $CurrDate is just a DateTime object and we use the AddDays() method to look back 30 days. It checks for any runs that aren't equal to "Success" and if that value is empty, we set it to the string "No Failed Backups"
Now, the resulting array is filled with PSCustomObjects, and these won't export to CSV very nicely since it will just put the string, so you'd need to write some further logic to make the report look like what you want. Play with that a bit in your lab and see how the objects are, and you can write some logic to pull data out of there and format it as your clients need it.
Not sure if this will help you, but it's what I'd start with to at least collect the data.
I punched out the framework for you on this a bit on Virtualized Backups (VMware/HyperV) but I'm not sure on the desired final format, so you might need to do some customizing. Similarly, likely this won't work for Nutanix/Agents based backups, that will require a bit of extra code. Tape Jobs also are "special", but not sure if your clients are needing this.
Code: Select all
$backups = Get-VBRBackup
$ReportDetails = @()
$OrphanedBackups = @()
$CurrDate = Get-Date
Foreach($b in $backups){
try {$job = $b.GetJob()}
catch {$OrphanedBackups += $b.name;continue}
$RestorePoints = Get-VBRRestorePoint -Backup $b
$RPCount = $RestorePoints | Select Name, Type | Sort Name -Unique |Group-Object -Property Name |select Name, Count
$Sessions = Get-VBRBackupsession | Where-Object {$_.Jobid -eq $job.id}
$FilteredSessions = $Sessions |Where-Object {$_.CreationTime -ge $CurrDate.AddDays(-30)}
$FailedSessions = $FilteredSessions | Where-Object {$_.Result -ne "Success"}
If(-not($FailedSessions)){
$FailedSessions = "No Backup Failures"
}
$JobDetails = [PSCustomObject]@{
JobName = $job.name
RestorePoints = $RPCount
SessionHistory = $FailedSessions
}
$ReportDetails += $JobDetails
}
$ReportDetails: Shows the name of the Job, the Restorepoints for each object in the job with their counts, and also reports on failed sessions.
$OrphanedBackups: Since I use a .NET method here and we can't use -ErrorAction or Out-Null, we try/catch on the GetJob() method and if it fails, we assume that there are backups without an associated job.
I chose to parse based on Get-VBRBackup as it's easier to get at Restorepoint data with this (fewer calls since we already have the backups and we can feed the CBackup object into Get-VBRRestorePoints). From there, we use GetJob() method on the CBackup Object to find its owner job, and then we process sessions from that job. $CurrDate is just a DateTime object and we use the AddDays() method to look back 30 days. It checks for any runs that aren't equal to "Success" and if that value is empty, we set it to the string "No Failed Backups"
Now, the resulting array is filled with PSCustomObjects, and these won't export to CSV very nicely since it will just put the string, so you'd need to write some further logic to make the report look like what you want. Play with that a bit in your lab and see how the objects are, and you can write some logic to pull data out of there and format it as your clients need it.
Not sure if this will help you, but it's what I'd start with to at least collect the data.
David Domask | Product Management: Principal Analyst
-
- Veteran
- Posts: 927
- Liked: 52 times
- Joined: Nov 05, 2009 12:24 pm
- Location: Sydney, NSW
- Contact:
Re: Custom Report for the last 30 days
Thanks, David, for sharing this report.
Would it be possible to also show the reason why the backup has failed?
Would it be possible to also show the reason why the backup has failed?
--
/* Veeam software enthusiast user & supporter ! */
/* Veeam software enthusiast user & supporter ! */
-
- Veeam Software
- Posts: 2038
- Liked: 501 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Custom Report for the last 30 days
Hi @albertwt,
You are very welcome.
Regrettably, the "reason" part is a bit of work to dig out.
post449831.html#p449831
The warnings can occur at two levels:
1. Job Level
2. Task level
The report right now just returns Job session histories, but each CBackupSession object has a method GetTaskSessions() which can be used to fetch the task sessions; this is not supported, but to make it supported you can pass the CBackupSession object to Get-VBRTaskSession and get the same results.
post449831.html#p449831
Each of the Session objects has a proper Logger, which has this information. You would need to write a bit of code to determine whether you should pull from the Job or Task session.
Alternatively, I would ask if it's feasible for your clients/purposes to just generate the HTML report from the UI: https://helpcenter.veeam.com/docs/backu ... ml?ver=110
You can do this from the History Tab and collect multiple jobs into the same report.
You are very welcome.
Regrettably, the "reason" part is a bit of work to dig out.
post449831.html#p449831
The warnings can occur at two levels:
1. Job Level
2. Task level
The report right now just returns Job session histories, but each CBackupSession object has a method GetTaskSessions() which can be used to fetch the task sessions; this is not supported, but to make it supported you can pass the CBackupSession object to Get-VBRTaskSession and get the same results.
post449831.html#p449831
Each of the Session objects has a proper Logger, which has this information. You would need to write a bit of code to determine whether you should pull from the Job or Task session.
Alternatively, I would ask if it's feasible for your clients/purposes to just generate the HTML report from the UI: https://helpcenter.veeam.com/docs/backu ... ml?ver=110
You can do this from the History Tab and collect multiple jobs into the same report.
David Domask | Product Management: Principal Analyst
Who is online
Users browsing this forum: No registered users and 4 guests