Removing a single VM from replicas

PowerShell script exchange

Removing a single VM from replicas

Veeam Logoby farge » Mon 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.
farge
Influencer
 
Posts: 12
Liked: 1 time
Joined: Fri Apr 15, 2011 1:26 pm

Re: Removing a single VM from replicas

Veeam Logoby v.Eremin » Mon 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

MERGED: Command / Script to exclude VMs from existing jobs

Veeam Logoby KarlW » Fri 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?
KarlW
Influencer
 
Posts: 10
Liked: never
Joined: Mon Jun 18, 2012 1:02 pm
Full Name: Karl Wallenius

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

Veeam Logoby v.Eremin » Fri 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] : remove item from job

Veeam Logoby AlexL » Fri 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
AlexL
Enthusiast
 
Posts: 52
Liked: never
Joined: Tue Aug 24, 2010 8:55 am
Full Name: Alex

Re: Removing a single VM from replicas

Veeam Logoby v.Eremin » Fri 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Removing a single VM from replicas

Veeam Logoby ThomasMc » Sat 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 :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Removing a single VM from replicas

Veeam Logoby v.Eremin » Mon 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests