There are a lot of times I find myself needing to take a one-off backup job of a VM – prior to software upgrades or patching I always like to take a backup of the affected VM(s) in the event that, well, you know, I mangle things. VeeamZip is great for this – it allows me to process a quick backup of my VM that is separate from its’ normal backup and replication routines. Since I deal in an environment that running paid Veeam licenses I have access to the Veeam Plug-in for the vSphere Web Client – and this plug-in does exactly what the title of this blog post is – it allows us to perform VeeamZips of our VMs without having to leave the vSphere Web Client and/or log into our Veeam Backup and Replication console.
What if I’m using Veeam Backup and Replication FREE?
So this is all great for me, but I got to thinking – What if I wasn’t running a paid version of Veeam Backup? What if I was simply running the free version – this doesn’t come with Enterprise Manager, therefore it doesn’t come with a means of getting the Veeam Backup and Replication Web Client plug-in installed – therefore no VeeamZip from the Web Client right? – Wrong! Ever since Veeam Backup and Replication v8 U2 came out they have been including PowerShell cmdlets around the VeeamZip functionality. I wrote about how to use it last year in Scheduling Veeam Free Edition Backups. Well, since we have PowerShell that means we can use vRealize Orchestrator to build a workflow around it – and we have the ability to execute workflows directly from within the vSphere Web Client – so without ado, Running the free VeeamZip functionality directly from the vSphere Web Client.
First up the script
I didn’t get too elaborate with the script as you can see below. This is simply a handful lines that take in a few parameters; the VM to backup, the destination to store the backup, and the retention, or autodeletion of the backup.
1 2 3 4 5 6 7 8 9 10 11 12 |
Param( [Parameter(Mandatory=$true)][string]$VM, [Parameter(Mandatory=$true)][string]$Destination, [Parameter(Mandatory=$true)][ValidateSet("Never","Tonight","TomorrowNight","In3days","In1Week","In2Weeks","In1Month")][string]$Autodelete ) #Load Veeam Toolkit & "C:\Program Files\Veeam\Backup and Replication\Backup\Initialize-VeeamToolkit.ps1" #Get the VM Veeam Entity. $vmentity = Find-VBRViEntity -Name $VM #VeeamZip it! Start-VBRZip -Entity $vmentity -Folder $destination -AutoDelete $Autodelete -DisableQuiesce |
That’s it for the script – simple right – feel free to take this and add whatever you seem fit to suit your needs 🙂
The Orchestrator Configuration
Before we get to creating our workflow there are a few things we need to do within orchestrator, mainly adding our server that hosts our Veeam Free instance as a PowerShell host within vRO. But even before we run the ‘Add a PowerShell Host’ workflow we need to run a few winrm commands on the Veeam Free instance. I have a complete post about setting up a PowerShell host here, but will include the commands you need to run below for quick reference.
First up, on the Veeam server run the following in a command shell…
- winrm quickconfig
- winrm set winrm/config/service/auth @{Kerberos=”true”}
- winrm set winrm/config/service @{AllowUnencrypted=”true”}
- winrm set winrm/config/winrs @{MaxMemoryPerShellMB=”2048″}
Next, from within vRO (as shown below) we can run the the “Add a PowerShell host” workflow…
As you can see my Veeam Server is actually the same as my vCenter server – don’t recommend doing this but hey it’s a small lab! Just be sure to use the FQDN of your Veeam Server for Host/IP column.
Ensure that the remote host type is WinRM, and that the Authentication method is set to Kerberos.
And be sure that we are passing our username in the ‘username@domain’ format, along with ‘Shared Session’ for the session mode. Once you are done go ahead and click ‘Submit’. If everything goes as planned your Veeam Backup and Replication server should be added as a PowerShell host within vRealize Orchestrator.
And now, the workflow!
Finally we can get to actually building our workflow. If you remember our script we take in three parameters; VM, Desitination and AutoDelete – so we will mimic the same with our workflow, only calling them Input Parameters within vRO (shown below)
Now since we will be using the built-in Powershell workflow ‘Invoke an External Script’ we will also need to have some workflow attributes setup in order to pass to that workflow. Below you can see how I’ve setup mine…
Your configuration may vary a little from this one, but as you can see we simply add a PowerShell host attribute and map it to our newly added host, as well assign the ScriptPath attribute to the representation of where we saved our little VeeamZip script earlier. The arguments attribute can remain empty as we will only use this to build the arguments string to pass to the script.
The first element we want to add to our workflow schema is a Scriptable task – go ahead and drag that over into your workflow. This is where we will create our arguments string.
As far as what goes into the scripting you can see I’ve simply brought in the arguments attribute, along with our three input parameters and simply chained them together into one string (arguments = ‘”‘+VM.name+'” “‘+Destination+'” “‘+AutoDelete+'”‘;), then ensured that my arguments attribute was included in the output as well.
Next drag the ‘Invoke an external script’ workflow into your schema (you can see I’ve renamed mine ‘Run VeeamZip’. Ignore all of the prompts regarding the setup of parameters that pop up – the easiest way I like to do this is by editing the workflow (the pencil above it) and using the ‘Visual Binding’ tab as shown below.
Simply drag and drop your in attributes to their corresponding in attributes on the external script workflow, along with mapping your output to output. Easy Peasy!
At this point you can go ahead and save and close your workflow – we are done with Orchestrator. If you want to run the workflow a few times to test from within vRO go ahead – but the point of this post was to run it from within the Web Client so let’s move on to that step.
vRO and vSphere Web Client
I love vRealize Orchestrator and I love the fact that I can contextually execute custom workflows from within the vSphere Web Client. To do this you need to first register your vRO instance with vCenter – this should be automatically done for you depending on you set everything up – I’m not going to get into that configuration today. To get to our context mappings we need to click on Home->vRealize Orchestrator. With the vRO Home in context select the ‘Manage’ tab and then ‘Context Actions’. We then are going to want to hit the little green + sign to add a new workflow context map.
As far as the next steps they are pretty self explanatory – navigate through your vRO inventory to your workflow, click ‘Add’, and select ‘Virtual Machine’ from the types box. This is what will allow us to right click on a VM and run our VeeamZip, passing the contextually selected VM to the workflow’s VM input parameter. Click ‘OK’ and it’s time to VeeamZip!
Now when you want to run the workflow you can simply right click a VM and navigate to (in my case) All vRealize Orchestrator Actions->VeeamZipVM
As you can see our workflow will start, using our VM selected as the VM input, and simply prompt us for the destination and AutoDelete settings.
And there you have it! We can now use the Free version of Veeam Backup and Replication to VeeamZip our VMs directly from within the vSphere Web Client. In fact, our workflow will even show up within our vSphere tasks so we can monitor the status of the job. Now, there is no error checking or anything like that…yet! Let me know if you have any questions, concerns, etc… always happy to read the comments!