PowerShell script exchange
Post Reply
Suryanarayanan
Influencer
Posts: 21
Liked: 3 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:

Powershell command to fetch the last 24 hours backup status is timed out

Post by Suryanarayanan »

Hi All,

I am using the below command to fetch the last 24 hours backup status of all our backed up VMs. it has been running fine for long time. But recently it is running for long time and giving time out.


# Fetch each backup job sessions from VBR for the last 24 hours
$vbrsessions = Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}

Backed up VMs count also increased from 1000 to 2000. Can somebody help to fix the issue?
david.domask
Veeam Software
Posts: 2639
Liked: 612 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell command to fetch the last 24 hours backup status is timed out

Post by david.domask » 1 person likes this post

Hi Suryanarayanan,

Timeouts are not expected, and we won't be able to troubleshoot over the forums as to why it's timing out, so please open a Support Case as is noted when creating a forum topic.

Please reproduce the issue, note the date and time of the reproduction, and then export logs for Support to review. (Use the 3rd radio button to export logs from a given server, and select the Veeam server itself for export).

Please share the case number here once you create it.

As for the actual issue, a quick question and a suggestion:

1. How long does it take before the timeout appears -- is it ~15 minutes by chance? Please note the approximate time for the timeout (you can simply open a new Powershell console from the Veeam Backup and Replication Menu (Menu > Console > Powershell) and then run:

Measure-Command -Expression {Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}}

That output would be useful information to include on the case

2. Consider using Get-VBRSession -- it returns a bit less information but still should be usable for reporting purposes. Because there's less back-end work for the cmdlet, it will return most of the relevant data much faster; if you need further data, you can pass an array of Session IDs returned from Get-VBRSession to Get-VBRBackupSession and the results will be significantly quicker. A quick example from one of my labs:

Code: Select all

PS C:\Users\Administrator> $Date = Get-Date
PS C:\Users\Administrator> $sessions = Get-VBRSession -Type Backup | Where-Object {$_.EndTime -ge $date.AddDays(-1)}
PS C:\Users\Administrator> $sessions


Progress     : 100
RunManually  : False
Log          : {Id: 148156, Usn: 1955697, Title: Job started at 9/10/2024 8:00:08 AM, Cookie: , Description: , Time:
               24/09/10 8:00:10 AM, StartTime: 24/09/10 8:00:10 AM, Status: Succeeded, Id: 148159, Usn: 1955712,
               Title: Building list of machines to process, Cookie: , Description: , Time: 24/09/10 8:00:12 AM,
               StartTime: 24/09/10 8:00:11 AM, Status: Succeeded, Id: 148173, Usn: 1955730, Title: VM size: 1024 MB (0
               B used), Cookie: , Description: , Time: 24/09/10 8:00:14 AM, StartTime: 24/09/10 8:00:14 AM, Status:
               Succeeded, Id: 148174, Usn: 1955733, Title: Changed block tracking is enabled, Cookie: , Description: ,
               Time: 24/09/10 8:00:15 AM, StartTime: 24/09/10 8:00:15 AM, Status: Succeeded...}
Name         : vmware-ffi-cap-bb
CreationTime : 24/09/10 8:00:08 AM
EndTime      : 24/09/10 8:01:38 AM
JobId        : 3439443e-b148-4e7d-9a33-3f2bb1fa0437
Result       : Warning
State        : Stopped
Id           : 661eebef-1ca8-44d0-8c57-ef732db83763


PS C:\Users\Administrator> Get-VBRBackupSession -Id $sessions.id

Job Name             State      Start Time             End Time               Result
--------             -----      ----------             --------               ------
vmware-ffi-cap-bb... Stopped    24/09/10 8:00:08 AM    24/09/10 8:01:38 AM    Warning
You can see the information returned by both cmdlets, and Get-VBRBackupSession has a bit more details, but the results of Get-VBRSession are faster and typically have most of what you need for basic reporting.
David Domask | Product Management: Principal Analyst
Suryanarayanan
Influencer
Posts: 21
Liked: 3 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:

Re: Powershell command to fetch the last 24 hours backup status is timed out

Post by Suryanarayanan »

Hi David,

Thanks for your response.

Support Case # 07412278.

1. Below command (Get-VBRBackupSession) has taken 3 hours 29 mins

Measure-Command -Expression {Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}}


2. Below command (Get-VBRSession) has taken 17 mins
Measure-Command -Expression {$sessions = Get-VBRSession -Type Backup | Where-Object {$_.EndTime -ge (Get-Date).addhours(-24)}
Get-VBRBackupSession -Id $sessions.id }

I have changed my script as per 2nd point and see the report is generating without any issue. I will monitor for a week and let you know if any issue.

Thanks for your reply again
david.domask
Veeam Software
Posts: 2639
Liked: 612 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell command to fetch the last 24 hours backup status is timed out

Post by david.domask » 1 person likes this post

Hi Suryanarayanan,

Thank you for opening the case and sharing it here, and glad to hear that the workaround brought the improved performance we were hoping for. This is supported and stable, so feel free to keep using it while Support reviews the data.

3 hours is a bit unexpected even on a fairly significantly sized environment, but let's see what Support finds on this one, and please continue to use the workaround for now; I've been recommending Get-VBRSession a lot more for situations like since typically it has everything you need and is just a bit faster, all while being supported.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests