backup single VM (not all VMs) within job?

PowerShell script exchange

[MERGED] start a job

Veeam Logoby sirinech » Thu Apr 10, 2014 1:17 pm

Hello,

Is it possible to start a job for a specific VM not all VMs inside it?
sirinech
Influencer
 
Posts: 23
Liked: 1 time
Joined: Fri Mar 21, 2014 3:06 pm
Full Name: sirine chadly

Re: backup single VM (not all VMs) within job?

Veeam Logoby foggy » Thu Apr 10, 2014 1:22 pm

Sirine, this can be performed with the help of PowerShell, please look above for details.
foggy
Veeam Software
 
Posts: 14752
Liked: 1083 times
Joined: Mon Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson

Re: backup single VM (not all VMs) within job?

Veeam Logoby rverhe » Wed Dec 10, 2014 9:48 am

This script don't work with V8. It does not readd my VMs in the job.
Is there an update?

Failure:

Method invocation failed because [Veeam.Backup.Core.CHierarchyObj] does not contain a method named 'GetItem'.
At I:\Scripts\VM-in-job.ps1:27 char:4
+ $Excitem = $obj.GetObject().GetItem()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Add-VBRViJobObject : Cannot validate argument on parameter 'Entities'. The argument is null. Provide a valid value for
the argument, and then try running the command again.
At I:\Scripts\VM-in-job.ps1:28 char:44
+ Add-VBRViJobObject -job $Job -Entities $Excitem
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-VBRViJobObject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.AddVBRViJobObject
rverhe
Novice
 
Posts: 4
Liked: never
Joined: Mon Dec 01, 2014 12:50 pm
Full Name: Rob Verhees

Re: backup single VM (not all VMs) within job?

Veeam Logoby v.Eremin » Wed Dec 10, 2014 5:37 pm

If you want to backup just one VM, why not to use Quick Backup that has been developed for such use cases specifically? Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: backup single VM (not all VMs) within job?

Veeam Logoby Backerupper » Fri Feb 06, 2015 4:43 pm

The script is still handy for backing up new VMs - Quick Backup will not work unless an initial backup has been created. Many folks like to add a VM to a job and back it up as part of their provisioning process.

The script has been updated for v8 here:
http://blog.smasterson.com/2015/02/06/veeam-v8-backing-up-a-single-vm-with-powershell/

Code: Select all
# Load Veeam snapin
Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
 
Clear-Host
Write-Host "Veeam Single VM Backup Script`n"
Write-Host "Notes:"
Write-Host "VM must be explicitly defined in the job"
Write-Host "VM can not be inherited by a folder, datastore or other object"
Write-Host "else it will get excluded as well and job will be empty."
Write-Host "Always confirm job completion via Veeam BR Console!"
 
# Check Veeam Version (Must be v8)
If ((Get-PSSnapin VeeamPSSnapin).Version.Major -ne 8) {
   Write-Host "You must be running VBR v8 to run this script...Exiting"
   Exit
}
 
# User Input
$jobName = Read-Host "Enter Job Name"
$vmName = Read-Host "Enter VM Name"
 
 
# Find the job that has our VM
$job = Get-VBRJob | ?{$_.Name -eq $jobName}
 
# Get all objects in job apart from our target VM
$execObjs = $job.GetObjectsInJob() | ?{$_.Name -ne $vmName}
 
# Exclude the objects from the job
Remove-VBRJobObject -Objects $execObjs
 
# Start the job only backing up the target VM
$runJob = Start-VBRJob -Job $job
 
# Find the exclude job objects
$incObjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Exclude"}
 
# Delete the exclude objects and re-add to job
foreach ($obj in $incObjs) {
    $Excitem = Find-VBRViEntity -Name $obj.Name
    Add-VBRViJobObject -job $Job -Entities $Excitem | Out-Null
    $obj.Delete()
}
 
Write-Host "`nBackup Complete"
Backerupper
Enthusiast
 
Posts: 42
Liked: 10 times
Joined: Fri Dec 28, 2012 2:32 pm

Re: backup single VM (not all VMs) within job?

Veeam Logoby ThomasMc » Tue Feb 17, 2015 9:30 pm

Many thanks for keeping these alive Shawn :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: backup single VM (not all VMs) within job?

Veeam Logoby KennethLarsen » Thu Jul 02, 2015 9:06 am

That script dont work here.. Posted it on the authors blog, but no response ! yeah i know I should fix it myself.. I havent.. !

Code: Select all
Add-VBRViJobObject : Cannot validate argument on parameter 'Entities'. The argument is null. Supply a non-null
argument and try the command again.
At C:\Install\Backup_1_VM_in_a_job.ps1:41 char:44
+     Add-VBRViJobObject -job $Job -Entities $Excitem | Out-Null
+                                            ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-VBRViJobObject], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.AddVBRViJobObject

Add-VBRViJobObject : Cannot validate argument on parameter 'Entities'. The argument is null. Supply a non-null
argument and try the command again.
At C:\Install\Backup_1_VM_in_a_job.ps1:41 char:44
+     Add-VBRViJobObject -job $Job -Entities $Excitem | Out-Null
+                                            ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-VBRViJobObject], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.AddVBRViJobObject
KennethLarsen
Novice
 
Posts: 8
Liked: 1 time
Joined: Mon Mar 03, 2014 7:21 am
Full Name: Kenneth Larsen

Re: backup single VM (not all VMs) within job?

Veeam Logoby v.Eremin » Thu Jul 02, 2015 10:38 am

So, the provided portion suggests that variable assignment went wrong and currently $ExcItem contains nothing.

Try to check code line by line and see which one doesn't return anything:
Code: Select all
$jobName = Read-Host "Enter Job Name"
$JobName

$job = Get-VBRJob | ?{$_.Name -eq $jobName}
$job

$incObjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Exclude"}
$incObjs

foreach ($obj in $incObjs) {
   $Excitem = $obj.GetObject().GetItem()
   $Excitem
}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: backup single VM (not all VMs) within job?

Veeam Logoby jelloir » Thu Aug 13, 2015 2:12 am

v.Eremin wrote:If you want to backup just one VM, why not to use Quick Backup that has been developed for such use cases specifically? Thanks.


Quick backup needs more flexibility and should offer an option of which backup source to choose as the quick backup. There may be situations where it's necessary to choose a particular backup job source rather than Veeam assuming you want to use the most recent backup.

For example... Just now we needed to choose an older backup of a VM as the source of the quick backup due to some changes being made with associating a copy job with that job and moving VM's to new backups. But because a newer backup of that VM existed from another job we had to delete the the newer backup to make Veeam run the quick backup from the source we required.

A simple "Use most recent backup" or "Choose source of backup" would be useful for quick backups.
jelloir
Novice
 
Posts: 5
Liked: 1 time
Joined: Thu May 07, 2015 11:45 pm

Re: backup single VM (not all VMs) within job?

Veeam Logoby v.Eremin » Thu Aug 13, 2015 10:10 am

Got it. However, I believe that in this particular case running a custom script would have been easier than deleting existing newer backups. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Backup single VM from larger job

Veeam Logoby GabesVirtualWorld » Mon Oct 24, 2016 10:15 am

Hi

Sometimes we have the need to make an extra backup of a single VM which is part of a larger job. For example before a big change, when snapshots are not desired.

Is there an easy way to do this? I don't want to create a new job because that would cause a complete full backup.

Regards
Gabrie
GabesVirtualWorld
Service Provider
 
Posts: 140
Liked: 10 times
Joined: Mon Jun 15, 2009 10:49 am
Full Name: Gabrie van Zanten

Re: backup single VM (not all VMs) within job?

Veeam Logoby v.Eremin » Mon Oct 24, 2016 10:31 am

I think Quick Backup is the functionality you're looking for. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: backup single VM (not all VMs) within job?

Veeam Logoby t481 » Mon Feb 13, 2017 7:58 am

Hello Veeam,
Clearly there's a lot of demand for this feature. Any chance this could be incorporated into a future release?
t481
Enthusiast
 
Posts: 30
Liked: never
Joined: Tue Apr 28, 2015 7:52 am

Re: backup single VM (not all VMs) within job?

Veeam Logoby v.Eremin » Mon Feb 13, 2017 6:13 pm

May I ask why Quick Backup functionality does not work for you? Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: backup single VM (not all VMs) within job?

Veeam Logoby rybaker » Wed Mar 01, 2017 8:54 pm

I agree this should be an added feature and here's why.

We just started backing up our sql trans logs with veeam. Made the changes to my existing job to a couple of sql servers and guess what? Error while trying to backup the trans logs! Veeam wants me to take a full backup of the VM again after making this change to backup the trans logs. I don't want to backup all of the VMs only the SQL servers that I made this change to. However I cant without running the whole job. :cry:
rybaker
Lurker
 
Posts: 1
Liked: never
Joined: Wed Mar 01, 2017 8:49 pm
Full Name: Ryan Baker

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests