-
- Influencer
- Posts: 14
- Liked: 3 times
- Joined: Mar 24, 2011 5:24 pm
- Contact:
How to generate list of VM in backup repository?
How to generate list of VM in backup repository?
Including VM already removed from vmware infrastructure, but available for restoring.
Including VM already removed from vmware infrastructure, but available for restoring.
-
- Veeam Software
- Posts: 2010
- Liked: 669 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: How to generate list of VM in backup repository?
In my everyday activities I use this simple script to choose a repo and then list unique vms backed up to it:
Hope it helps!
Code: Select all
$repos = Get-VBRBackupRepository
$sobrs = Get-VBRBackupRepository -ScaleOut
$repoList = @()
foreach ($repo in $repos) {
$repoList += $repo | select Id, Name
}
foreach ($sobr in $sobrs) {
$repoList += $sobr | select Id, Name
}
$repoList.Name
$repoChosen = Read-Host -Prompt 'Choose repository name'
$repoChosen = $repoList | where {$_.Name -eq $repoChosen}
$backups = Get-VBRBackup | where {$_.RepositoryId -eq $repoChosen.Id}
$objectsList = @()
foreach ($backup in $backups) {
$objects = $backup.GetObjects()
$objectsList += $objects | select Name
}
$objectsList | sort -Unique
-
- Influencer
- Posts: 14
- Liked: 3 times
- Joined: Mar 24, 2011 5:24 pm
- Contact:
Re: How to generate list of VM in backup repository?
Thank you!
nice start.
But after enter repository name, I got name of one of vm data storages.
But I need list of virtual machines from repository and job, as on screenshot below.
What type of object should I look for, or what GET-??? to use, or what to iterate to get list as on a screenshot?
nice start.
But after enter repository name, I got name of one of vm data storages.
But I need list of virtual machines from repository and job, as on screenshot below.
What type of object should I look for, or what GET-??? to use, or what to iterate to get list as on a screenshot?
-
- Veeam Software
- Posts: 2010
- Liked: 669 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: How to generate list of VM in backup repository?
Hi,
Considering that the output in Powershell is plain and to present data with tree-like structure as shown on the screenshot would require some tricks, here is the closest Powershell interpretation I could think of:
Thanks,
Oleg
Considering that the output in Powershell is plain and to present data with tree-like structure as shown on the screenshot would require some tricks, here is the closest Powershell interpretation I could think of:
Code: Select all
$backups = Get-VBRBackup
$repos = Get-VBRBackupRepository
$sobrs = Get-VBRBackupRepository -ScaleOut
$repoList = @()
foreach ($repo in $repos) {
$repoList += $repo | select Id, Name
}
foreach ($sobr in $sobrs) {
$repoList += $sobr | select Id, Name
}
foreach ($backup in $backups) {
$targetRepo = $repoList | where {$_.Id -eq $backup.RepositoryId}
$objects = $backup.GetObjects()
foreach ($object in $objects) {
$rps = Get-VBRRestorePoint -ObjectId $object.Id
$rpFirst = $rps | sort -Property CreationTime | select -Last 1
$object | select Name, @{n='RPCount';e={$rps.Count}}, @{n='CreationTime';e={$rpFirst.CreationTime}}, @{n='Backup';e={$backup.Name}}, `
@{n='Repository';e={$targetRepo.Name}}, @{n='Platform';e={$_.Platform.ToString()}} | fl
}
}
Oleg
-
- Influencer
- Posts: 14
- Liked: 3 times
- Joined: Mar 24, 2011 5:24 pm
- Contact:
Re: How to generate list of VM in backup repository?
Thank you, Oleg!
My final variant:
My final variant:
Code: Select all
PS > Get-VBRBackup | where { $_.VmCount -gt 0 -and $_.Name -eq "offcopy"} | % { $_.Name; Get-VBRRestorePoint -Backup $_.Name | select Name -
uniq| Sort-Object {$_.Name} | % { Get-VBRRestorePoint -Name $_.Name | Sort-Object {$_.CreationTime.toString("yyyyMMddHH")} | select -First 1 } } >offc
opy-vm.txt
Who is online
Users browsing this forum: No registered users and 10 guests