-
- Veteran
- Posts: 942
- Liked: 53 times
- Joined: Nov 05, 2009 12:24 pm
- Location: Sydney, NSW
- Contact:
Powershell to list Backup Job name, VMs and its retention?
Hi Experts,
Can anyone here please share the PowerShell script to list Veeam Backup Job name, its VM content and the Retention policy for each backup job?
Any other methods are welcome.
Thank you in advance.
Can anyone here please share the PowerShell script to list Veeam Backup Job name, its VM content and the Retention policy for each backup job?
Any other methods are welcome.
Thank you in advance.
--
/* Veeam software enthusiast user & supporter ! */
/* Veeam software enthusiast user & supporter ! */
-
- Influencer
- Posts: 17
- Liked: 4 times
- Joined: Nov 16, 2018 3:14 pm
- Full Name: Lucas HELLMANN
- Location: Lyon, FRANCE
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hello,
I would have done something like this :
it may not be the best script but It will do the job.
Cheers,
Lucas.
I would have done something like this :
Code: Select all
asnp VeeamPSSNapin
$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"}
Foreach ($job in $Jobs) {
$Objs = $job.GetObjectsInJob()
$VMList = @()
Foreach ($obj in $Objs) {
$VMList=$VMList+$obj.Name
}
$Option = $Job.BackupStorageOptions.RetainCycles
$JobName = $Job.Name
Write-Host $JobName "`nRetention period : " $Option "`nVM List : " $VMList
}
Cheers,
Lucas.
-
- Veteran
- Posts: 942
- Liked: 53 times
- Joined: Nov 05, 2009 12:24 pm
- Location: Sydney, NSW
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Many thanks Lucas,
Would it be possible to list the size of the backup with the script below and the Backup Repository it is located?
Would it be possible to list the size of the backup with the script below and the Backup Repository it is located?
Code: Select all
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
$JobName = $_.Name
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}} | Sort -Property Job, Name
}
--
/* Veeam software enthusiast user & supporter ! */
/* Veeam software enthusiast user & supporter ! */
-
- Influencer
- Posts: 17
- Liked: 4 times
- Joined: Nov 16, 2018 3:14 pm
- Full Name: Lucas HELLMANN
- Location: Lyon, FRANCE
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hello,
Did some modification with the script I posted and what you posted :
This script check for each VM in a Backup Job :
I didn't look much further to optimize it, I think the slow point is when it checks for the repository path, the two foreach doesn't help much either as I'm far from being a powershell expert.
Tell me if this works for you
Cheers,
Lucas
Did some modification with the script I posted and what you posted :
Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$RepositoryPath = $Backup.Info.DirPath.ToString()
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
- The VMSize
- The number of restore points available on disk
- The last backup result and the start Time
- The last backup : total size and data copied on disk
- And the repository path (I'm not sure if this is what you wanted ?)
I didn't look much further to optimize it, I think the slow point is when it checks for the repository path, the two foreach doesn't help much either as I'm far from being a powershell expert.
Tell me if this works for you
Cheers,
Lucas
-
- Veteran
- Posts: 942
- Liked: 53 times
- Joined: Nov 05, 2009 12:24 pm
- Location: Sydney, NSW
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Lucas,
Thank you for your help in this matter, somehow it is returning the below error instead of any result?
$RepositoryPath = $Backup.Info.DirPath.ToString()
Thank you for your help in this matter, somehow it is returning the below error instead of any result?
Which refers to this line:You cannot call a method on a null-valued expression.
At line:15 char:9
+ $RepositoryPath = $Backup.Info.DirPath.ToString()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
$RepositoryPath = $Backup.Info.DirPath.ToString()
--
/* Veeam software enthusiast user & supporter ! */
/* Veeam software enthusiast user & supporter ! */
-
- Influencer
- Posts: 17
- Liked: 4 times
- Joined: Nov 16, 2018 3:14 pm
- Full Name: Lucas HELLMANN
- Location: Lyon, FRANCE
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hello,
Yes I had this problem on some backup too, I had this solved but I didn't post the up to date one.
This is because you may have changed the job name at some point but the backup name didn't change with it.
In my case : I had job like : Job-CLIENT before and now I have Job-CLIENT-HPV or (VMW depending on the infrastucture). So If you are in a similar situation, the script below might work.
To correct it I added a little if loop that check if the Backup here is null : $Backup = Get-VBRBackup -Name $JobName
If it is empty, I know that in my case I will have to crop the end to get the right backup corresponding to the job.
Here the code to add just after $Backup = Get-VBRBackup -Name $JobName
Another solution would be to rename the Job to the correct Backup name, it should work too.
Cheers,
Lucas
Yes I had this problem on some backup too, I had this solved but I didn't post the up to date one.
This is because you may have changed the job name at some point but the backup name didn't change with it.
In my case : I had job like : Job-CLIENT before and now I have Job-CLIENT-HPV or (VMW depending on the infrastucture). So If you are in a similar situation, the script below might work.
To correct it I added a little if loop that check if the Backup here is null : $Backup = Get-VBRBackup -Name $JobName
If it is empty, I know that in my case I will have to crop the end to get the right backup corresponding to the job.
Here the code to add just after $Backup = Get-VBRBackup -Name $JobName
Code: Select all
if ($Backup -eq $null) {
$BackupName = $JobName.Remove(7,4) #The number are for my case, you might changed it
$Backup = Get-VBRBackup -Name $BackupName }
else {}
Cheers,
Lucas
-
- Novice
- Posts: 7
- Liked: never
- Joined: Feb 10, 2020 7:46 am
- Full Name: Alberto Cepero
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi all!!
I understand that the final script should look like this, right?
Anyway, only VM takes me out that are no longer copied, it is not able to remove all existing VMs.
In the second line of the code should I put the name of the job? I do it and it doesn't give me anything back
Thank you so much for your help
I understand that the final script should look like this, right?
Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
if ($Backup -eq $null) {
$BackupName = $JobName.Remove(7,4)
$Backup = Get-VBRBackup -Name $BackupName }
else {
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$RepositoryPath = $Backup.Info.DirPath.ToString()
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
}
In the second line of the code should I put the name of the job? I do it and it doesn't give me anything back
Thank you so much for your help
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Alberto,
Yes, should be it. In my lab it works perfectly.
But do you mean this or else?
Best regards,
Oleg
Yes, should be it. In my lab it works perfectly.
Sorry, what do you mean by that?Anyway, only VM takes me out that are no longer copied, it is not able to remove all existing VMs.
This script returns info for all backup jobs, so there is no need to specify the name.In the second line of the code should I put the name of the job? I do it and it doesn't give me anything back
But do you mean this or else?
Code: Select all
asnp VeeamPSSnapin
Get-VBRJob -name "BACKUP-TO-SOBR"| ?{$_.JobType -eq "Backup"} | %{
Oleg
-
- Veteran
- Posts: 942
- Liked: 53 times
- Joined: Nov 05, 2009 12:24 pm
- Location: Sydney, NSW
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Oleg,
yes, your script is working as expected.
Since it is executed against Veeam Backup & Replication 10.0.0.4461
There is
yes, your script is working as expected.
Since it is executed against Veeam Backup & Replication 10.0.0.4461
There is
WARNING: This cmdlet is obsolete and no longer supported. To get computer backup job use "Get-VBRComputerBackupJob" instead.
--
/* Veeam software enthusiast user & supporter ! */
/* Veeam software enthusiast user & supporter ! */
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi @albertwt,
It makes sense if you run it against agent backup jobs since we have a whole set of new cmdlets to manage them
Best regards,
Oleg
It makes sense if you run it against agent backup jobs since we have a whole set of new cmdlets to manage them
Best regards,
Oleg
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Just a tip - to avoid unnecessary warnings you can input WarningAction parameter with "SilentlyContinue" as its value. Thanks!
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hello All
Get-VBRJob only gives me VMware backup jobs and there are different hypervisor in veeam backup application.
Is there any other command to get list of all the jobs showing in home -> Jobs -> Backup ?
Using Get-VBRBackup gives list of all jobs but not the vm inside each job and size other details.
Any help would be appreciated.
Get-VBRJob only gives me VMware backup jobs and there are different hypervisor in veeam backup application.
Is there any other command to get list of all the jobs showing in home -> Jobs -> Backup ?
Using Get-VBRBackup gives list of all jobs but not the vm inside each job and size other details.
Any help would be appreciated.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Sumeet,
Get-VBRJob works for VMware and Hyper-V, so should be no issues here.
As for Nutanix, it is represented as custom platform (BackupPlatform: ECustomPlatform). But you still can retrieve related backup jobs along with those of other platforms using .NET method below:
Thanks,
Oleg
Get-VBRJob works for VMware and Hyper-V, so should be no issues here.
As for Nutanix, it is represented as custom platform (BackupPlatform: ECustomPlatform). But you still can retrieve related backup jobs along with those of other platforms using .NET method below:
Code: Select all
[Veeam.Backup.Core.CBackupJob]::GetAll()
Oleg
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Oleg
Is there any way to do it in Powershell?
As of now i don't want to use .NET
Is there any way to do it in Powershell?
As of now i don't want to use .NET
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
You can run that exact code in PowerShell.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
As i need details of all job which is appearing like:
job Name:
job per vm:
per vm size:
retention policy:
Using these command [Veeam.Backup.Core.CBackupJob]::GetAll() which is equal to using GET-VBRBackup gives all jobs result but how can i achieve every job details.
using below scripts gives only Vmware and hyper-V, how can i get all other jobs detail?
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$RepositoryPath = $Backup.Info.DirPath.ToString()
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
job Name:
job per vm:
per vm size:
retention policy:
Using these command [Veeam.Backup.Core.CBackupJob]::GetAll() which is equal to using GET-VBRBackup gives all jobs result but how can i achieve every job details.
using below scripts gives only Vmware and hyper-V, how can i get all other jobs detail?
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$RepositoryPath = $Backup.Info.DirPath.ToString()
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
It is not equivalent to Get-VBRBackup, but rather Get-VBRJob.
You can take what Oleg posted and capture it into a variable, or just use it to replace Get-VBRJob in line 2 of your code.
You can take what Oleg posted and capture it into a variable, or just use it to replace Get-VBRJob in line 2 of your code.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
okay i got it.As you suggested i have replaced the line in above code but it throws error.
You cannot call a method on a null-valued expression.
At C:\Untitled11.ps1:12 char:29
+ foreach($tasksession in $lastsession.GetTaskSessions()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
the new code is :
asnp VeeamPSSnapin
[Veeam.Backup.Core.CBackupJob]::GetAll() | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$Option = $Job.BackupStorageOptions.RetainCycles
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="RetentionPoint"; E={$Option}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}} | Sort -Property Job, Name
}
You cannot call a method on a null-valued expression.
At C:\Untitled11.ps1:12 char:29
+ foreach($tasksession in $lastsession.GetTaskSessions()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
the new code is :
asnp VeeamPSSnapin
[Veeam.Backup.Core.CBackupJob]::GetAll() | %{
$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$Option = $Job.BackupStorageOptions.RetainCycles
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="RetentionPoint"; E={$Option}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}} | Sort -Property Job, Name
}
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
That means that at least one of your backup sessions doesn’t have a valid task session.
You should capture the results of $lastsession.GetTaskSessions() into a variable first and then run your for each loop against that.
The real issue is that you don’t have any logic or error handling to check for invalid input before that entire code lock runs, so even the ab,I’ve fix may not resolve everything.
You should capture the results of $lastsession.GetTaskSessions() into a variable first and then run your for each loop against that.
The real issue is that you don’t have any logic or error handling to check for invalid input before that entire code lock runs, so even the ab,I’ve fix may not resolve everything.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
okay got your point, so still stuck is there any work around to get the following details of the job which is not be shown by GET-VBRJob?
job Name:
job per vm:
per vm size:
last result:
job Name:
job per vm:
per vm size:
last result:
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Sumeet,
Answering your question,
Job name:
Per vm size:
It's a size of VM being backed up.
Or do you mean something else?
Last result:
Thanks,
Oleg
Answering your question,
Job name:
Code: Select all
$job = Get-VBRJob -Name 'JobName'
$job.Name
I don't quite understand. Do you mean task sessions for each vm in a job?Job per vm
Per vm size:
Code: Select all
$job = Get-VBRJob -Name 'JobName'
$objects = Get-VBRJobObject -Job $job
foreach ($object in $objects) {
$object.ApproxSizeString
}
Or do you mean something else?
Last result:
Code: Select all
$job = Get-VBRJob -Name 'JobName'
$job.Info.LatestStatus
# or
$job.GetLastResult()
Oleg
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hello Oleg
Thank you for the response but i want the last result for Get-VBRBackup like
$job = Get-VBRBackup -Name 'JobName'
$job.Info.LatestStatus
but it seems "Info.LatestStatus" or getLastResult() is not property of get-vbrbackup command.
as get-vbrbackup job gives me all the jobs including agent jobs. so i wanted the result of jobs using command get-vbrbackup
Thank you for the response but i want the last result for Get-VBRBackup like
$job = Get-VBRBackup -Name 'JobName'
$job.Info.LatestStatus
but it seems "Info.LatestStatus" or getLastResult() is not property of get-vbrbackup command.
as get-vbrbackup job gives me all the jobs including agent jobs. so i wanted the result of jobs using command get-vbrbackup
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
That's because a backup is the result of a job running. They are mostly linked but not always. Imagine a job that has not run yet, there are no "backups" or a "last result". Or if you import a backup (or remove a job), there is no job for that specific backup
From a backup, you can try to find the related job (but again, it might not be linked if it is an imported backup)
But not sure if this is really what you want
You can pipe an object to get-member or gm to get it's properties. E.g
From a backup, you can try to find the related job (but again, it might not be linked if it is an imported backup)
Code: Select all
$backup.GetJob()
You can pipe an object to get-member or gm to get it's properties. E.g
Code: Select all
get-vbrbackup | gm
-
- Novice
- Posts: 7
- Liked: never
- Joined: Aug 12, 2020 1:37 pm
- Full Name: Sumeet Singh
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Lucas_H, how can i retrieve data like transfered data , duration of backup and message if the backup failed or warning add to these upper script?
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi @sumeet.singh,
All that info you mentioned is related to backup session. You can retrieve it with the following sample script:
Thanks,
Oleg
All that info you mentioned is related to backup session. You can retrieve it with the following sample script:
Code: Select all
$job = Get-VBRJob -Name 'JobName'
$session = Get-VBRBackupSession -Name "$($job.Name)*" | select -Last 1 #retrieves the last session for the job chosen.
$session.Progress.TransferedSize
$session.Progress.Duration.ToString()
$session.Result
Oleg
-
- Novice
- Posts: 4
- Liked: never
- Joined: Jun 18, 2020 5:15 am
- Full Name: Ryan C
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
This is all good, however I seem to have thrown a wrench into thing using only VM tags as my VM targets in a job.
Name output is shown only as the tags not VM objects in the job.
Any ideas on how to loop through session info per job at a tag level?
Name output is shown only as the tags not VM objects in the job.
Any ideas on how to loop through session info per job at a tag level?
-
- Novice
- Posts: 4
- Liked: never
- Joined: Jun 18, 2020 5:15 am
- Full Name: Ryan C
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Also curious on proper usage of Get-VBRRetentionPolicy
My job has GFS set, however Get-VBRRetentionPolicy output of a given job shows as simple? Maybe another byproduct of tag usage rather than direct VM objects in a job?
My job has GFS set, however Get-VBRRetentionPolicy output of a given job shows as simple? Maybe another byproduct of tag usage rather than direct VM objects in a job?
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Hi Ryan,
First, in regards to tags. Objects you add directly to your job don't have any other children. So, if you add any entity container (VM tag, resource pool, folder etc.), you cannot just expand all the entities within as on this stage it is not an inventory anymore.
If you need to get VM names inside VM tags, you can use PowerCLI to retrieve VM by tags you added to the job.
Now, about Get-VBRRetentionPolicy. As the article states, this cmdlet returns retention policy solely for backup copy jobs of certain types.
So, may not work correctly with other types.
Thanks,
Oleg
First, in regards to tags. Objects you add directly to your job don't have any other children. So, if you add any entity container (VM tag, resource pool, folder etc.), you cannot just expand all the entities within as on this stage it is not an inventory anymore.
If you need to get VM names inside VM tags, you can use PowerCLI to retrieve VM by tags you added to the job.
Now, about Get-VBRRetentionPolicy. As the article states, this cmdlet returns retention policy solely for backup copy jobs of certain types.
So, may not work correctly with other types.
Thanks,
Oleg
-
- Novice
- Posts: 4
- Liked: never
- Joined: Jun 18, 2020 5:15 am
- Full Name: Ryan C
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
Thanks Oleg,
Do you have any reference on recursion of the VM objects from tags.
What I am ultimately after is where this thread started, to report retention of specific VM items inside a job, to ensure adherence to GFS.
I can see the default retention (days/Backup Points) is easily derived, but I am still confused on getting a visual for GFS retention points.
Understood that Get-VBRRetentionPolicy only applies to Backup Copy jobs
Do you have any reference on recursion of the VM objects from tags.
What I am ultimately after is where this thread started, to report retention of specific VM items inside a job, to ensure adherence to GFS.
I can see the default retention (days/Backup Points) is easily derived, but I am still confused on getting a visual for GFS retention points.
Understood that Get-VBRRetentionPolicy only applies to Backup Copy jobs
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Powershell to list Backup Job name, VMs and its retention?
By getting VMs by VM tags backed up I meant this sample:
But if you are after checking restore points count for VMs already backed up in per-VM backup chain,
you can try this:
It should also work if VM tags are job objects.
Code: Select all
$job = Get-VBRJob
Connect-VIServer -Server 'vcenter'
$tag = Get-VBRJobObject -Job $job
$vms = Get-VM -Tag $tag.Name
you can try this:
Code: Select all
$job = Get-VBRJob -Name 'Backup job'
$backup = Get-VBRBackup -Name $Job.Name
$objects = $backup.GetObjects()
foreach ($object in $objects) {
$storages = $backup.GetAllStorages() | where {$_.FilePath -match $object.Name}
$object | select Name, @{n='RPCount';e={$storages.Count}}
}
Who is online
Users browsing this forum: No registered users and 12 guests