PowerShell script exchange
Post Reply
farge
Influencer
Posts: 12
Liked: 1 time
Joined: Apr 15, 2011 1:26 pm

Removing a single VM from replicas

Post by farge » Oct 29, 2012 12:06 pm 1 person likes this post

Hello,

in a Powershell script I need to delete (from disk) only a particular replica VM among all those created by a given Veeam 6.1 replication job (ie, looking at Veeam shell under "Replicas" and expanding the replica set with the name of the job, I need to just remove (and delete from disk) VM1, leaving VM2 and VM3 in place).
Can someone please provide an example of how to do that through Veeam cmdlets? I tried using remove-vbrrestoreplica and the command seems to complete successfully but the replica VM does not get deleted,
Here's what I tried:

Get-VBRReplica -Name "Test Replication Job" | get-vbrrestorepoint | remove-vbrrestorepoint -Name VM1

TIA
E.

veremin
Product Manager
Posts: 17063
Liked: 1474 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Removing a single VM from replicas

Post by veremin » Nov 12, 2012 2:58 pm

Hi.

As far as I can understand, you did only part of all necessary actions.

Step-by-step plan for your issue should look like this:

1.Find and select the job that has the VM-object you’re going to exclude.
2.Find and select the VM-object you’re going to exclude.
3.Exclude the VM-object from this job.
4.Delete the excluded object.
5.Delete restore point related to the VM.

In PowerShell console:

Code: Select all

$job=Get-VBRJob | ?{$_.Name –eq “Name of your job”}
$object=Get-VBRJobObject –job ($job)| ?{$_.Name –eq “Name of you VM-object”}
Remove-VBRJobObject –job ($job) –object ($object)
$object.delete()
Get-VBRReplica | ?{$_.Name –eq “Name of your job”}| Get-VbrRestorePoint| ?{$_.VMName –eq “Name of you VM”}|Remove-VBRRestorePoint
That’s all.

Truth be told, I’ve used this script in earnest. Still, for the purpose of complete safety I strongly recommend you trying it first in test environment before implementing.

Hope this helps.
Thanks.

KarlW
Influencer
Posts: 10
Liked: never
Joined: Jun 18, 2012 1:02 pm
Full Name: Karl Wallenius
Contact:

MERGED: Command / Script to exclude VMs from existing jobs

Post by KarlW » Nov 16, 2012 12:38 pm

Hello there,

In our environment we base our backup jobs on datastorage (one job per datastore). Since VMs in a large enviornment like ours move around from time to time.

I would like to exclude a couple of VMs on all jobs we have. Is there a good cmd-let to manage exclusions in a fairly smooth manner?

veremin
Product Manager
Posts: 17063
Liked: 1474 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: MERGED: Command / Script to exclude VMs from existing jo

Post by veremin » Nov 16, 2012 12:55 pm

KarlW wrote:Hello there,

In our environment we base our backup jobs on datastorage (one job per datastore). Since VMs in a large enviornment like ours move around from time to time.

I would like to exclude a couple of VMs on all jobs we have. Is there a good cmd-let to manage exclusions in a fairly smooth manner?
Hi, Karl.

Please take a look at the script provided above. I think, it's exactly want you need.

Furthermore, if you want to exclude this VMs only temporarily, just skip the part responsible for deleting the excluded object and for removing associated restore points.

Thanks.

AlexL
Enthusiast
Posts: 58
Liked: never
Joined: Aug 24, 2010 8:55 am
Full Name: Alex
Contact:

[MERGED] : remove item from job

Post by AlexL » Jul 26, 2013 1:16 pm

I've been struggling to remove an object, in my case a vmware folder, from an existing backup job. So far without any luck.

If anyone could please post a few lines of code I'd be a very happy guy.

Thanks,
Alex

veremin
Product Manager
Posts: 17063
Liked: 1474 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Removing a single VM from replicas

Post by veremin » Jul 26, 2013 1:24 pm

Hi, Alex. The following code should meet your expectations:

Code: Select all

Asnp VeeamPSSnapin 
$Job = Get-VBRJob -name "Name of your Job"
$ObjectToRemove = $Job | Get-VBRJobObject -name "Name of a folder you’re going to exclude"
$ObjectToRemove | Remove-VBRJobObject #this line will exclude a given object
$ObjectToRemove.delete() #this line will remove a given object from the job completely
Hope this helps.
Thanks.

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Removing a single VM from replicas

Post by ThomasMc » Jul 27, 2013 6:51 pm 1 person likes this post

Code: Select all

Remove-VBRJobObject 
Also has the -Completely flag which will save some code :)

veremin
Product Manager
Posts: 17063
Liked: 1474 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Removing a single VM from replicas

Post by veremin » Jul 29, 2013 9:11 am

I must have totally missed this switch; thanks for pointing it out.

So, the shortened version of the aforesaid script should look like this:

Code: Select all

Asnp VeeamPSSnapin 
$Job = Get-VBRJob -name "Name of your Job"
$ObjectToRemove = $Job | Get-VBRJobObject -name "Name of a folder you’re going to exclude"
$ObjectToRemove | Remove-VBRJobObject -completely 

Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests