Recently I successfully used a script to remove a list of VMs from a set of replication jobs because I believe the instant VM recovery feature is so fast that having a replica is no longer justified for some VMs. (Way the go Veeam!) The replicas however still show up under the ‘Replicas’ section.
I understand the ‘Remove-VBRReplica -FromDisk’ command can be used to clean them up. However the documentation tells me to use the ‘Get-VBRReplica’ command to make the initial selection of VMs. This is where I run into trouble. ‘Get-VBRReplica’ doesn’t seem to return the VM replicas as the documentation states. But instead returns the jobs they once belonged to. This makes it seemingly impossible for me to select the VMs I removed before since the job still exists and I don’t want to remove ALL replicas.
Since this is such a common function, my question to the community is: How do you guys list and remove Orphaned replicas with powershell?
-
- Enthusiast
- Posts: 32
- Liked: 6 times
- Joined: Apr 05, 2023 1:06 pm
- Full Name: maanlicht
- Contact:
-
- Veeam Software
- Posts: 1520
- Liked: 661 times
- Joined: Jul 17, 2015 6:54 pm
- Full Name: Jorge de la Cruz
- Contact:
Re: How to list and remove Orphaned replicas
Unfortunately, there's no direct way to get a list of orphaned VMs using Get-VBRReplica cmdlet, since it returns the list of replica jobs and not the individual VM replicas.
I have tried a few cmdlets and some commands, but nothing drove me far.
Will wait for others that maybe have achieved this with a bit of extra scipting.
I have tried a few cmdlets and some commands, but nothing drove me far.
Will wait for others that maybe have achieved this with a bit of extra scipting.
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software
@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
Senior Product Manager | Veeam ONE @ Veeam Software
@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
-
- Veeam Software
- Posts: 2015
- Liked: 671 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: How to list and remove Orphaned replicas
Hi,
Orphaned replicas are the ones that have JobId property nulled. I'd also filter them by IsImported: $false since we are working with CBackup types here even though replicas cannot really be imported in a sense backups can be:
Let me know if the output for the code I provided corresponds to your list of orphaned replicas.
Best regards,
Oleg
That's not the case, Get-VBRReplica still returns replicas, not the jobs. The difference being is that in the UI we present replicas by VM names, whereas in powershell we present them by job names (true for VMware and Hyper-V replicas, vCD replicas are still presented by VM names). It happens because VMware and Hyper-V replicas don't have their own type in PS and are presented as CBackup. Hence, the schema for CBackup gets applied to these replica types as well. To see that these are, in fact, replicas, you can double check it through DB Manager classes:‘Get-VBRReplica’ doesn’t seem to return the VM replicas as the documentation states. But instead returns the jobs they once belonged to.
Code: Select all
$replica = Get-VBRReplica
[Veeam.Backup.DBManager.CDBManager]::Instance.Replicas.GetReplicasFromBackup($replica[0].Id)
Code: Select all
$orphanedReplicas = Get-VBRReplica | where {$_.IsImported -eq $false -and $_.JobId -eq '00000000-0000-0000-0000-000000000000'}
$orphanedReplicas
Best regards,
Oleg
-
- Enthusiast
- Posts: 32
- Liked: 6 times
- Joined: Apr 05, 2023 1:06 pm
- Full Name: maanlicht
- Contact:
Re: How to list and remove Orphaned replicas
@oleg.feoktistov thankyou that is very helpful information and good to know about the DB Manager classes.
I tested nulled JobId trick in my lab but unfortunately it does not show orphaned VMs if the original job still exists and is in use. However after removing the job it indeed lists ALL the VMs as orphaned replicas. So it looks like the JobId only changes for an orphan if the parent job gets removed.
Do you know of any other way?
I tested nulled JobId trick in my lab but unfortunately it does not show orphaned VMs if the original job still exists and is in use. However after removing the job it indeed lists ALL the VMs as orphaned replicas. So it looks like the JobId only changes for an orphan if the parent job gets removed.
Do you know of any other way?
Who is online
Users browsing this forum: No registered users and 8 guests