Veeam Software offers a tied integration with VMware vCloud Director. It includes a self-service portal, but what are your options if you wish to build your own self-service portal, or integrate with your existing portal?
Last week I was working with a Veeam Service Provider who wanted to build a predefined vCloud Director to develop backup policies that his tenants could choose with PowerShell. I proposed that these easy PowerShell commands would be useful to him; and to get you started, I will run through them here:
- Create Veeam vCD Backup job with differential retention
- Modify the Backup Restore Point to Keep
- Modify the backup job schedule
- Assign a specific Proxy for each tenant if needed
- Put everything together on a Powershell Menu for Tenants to choose the policy
So let’s get started.
Define Global Variable
First, we must define the variables we will be using on our script:
Note: I will use my vCD tenant Org name here.
$vCDSrvName = “Enter Your vCD Server Host Name “
$vBRRepoName = “Enter Your Repository Name”
$vProxyName = “Enter the Proxy Name if you wish to assign Proxy Manually”
$vCDOrgName = “Enter the Orgname”
Job Customization Options
Now to define the parameters to be used to customize the backup job. We will set the Schedule time and Restore Point to Keep
$RunTime =”23:00″
$retention = New-VBRJobOptions -ForBackupJob
$retention.BackupStorageOptions.RetainCycles = 31
Set Veeam backup environment
Before we begin creating the Veeam vCD backup job, we must set the Veeam backup infrastructure. We will setup these items; vCloud Server Name, vAPP Name, Proxy and Repository name to be used with Veeam Get-XXX Powershell command later on:
$vcdServer = get-vbrserver -name $vCDSrvName
$backupRepo = Get-VBRBackupRepository -name $vBRRepoName
$proxy = get-vbrviproxy -name $vProxyName
$vCDvApps = Find-VBRvCloudEntity -Server $vcdServer -vApp
Include all the vApp per Organization in the backup Job
Sometimes the Tenant has multiple vApps under his Organization; therefore, it’s nice to capture all the vApps and put each of them in a different backup job:
$vCDvApps = $vCDvApps| ? { $_.Type -eq ‘vApp’ -and $_.Path -match $vCDOrgName }
$vcdJobs = $vCDvApps | % { Add-VBRvCloudJob -name “Enter Job Name – $($_.name)” -description “Enter the description of the Backup Job” -entity $_ -BackupRepository $vBRRepoName }
Customize the vCD Backup Job Options
Now let’s customize the backup job by changing several backup job options; such as, the Schedule, Proxy and the Restore point to Keep:
$vcdJobs | % { set-vbrjobproxy -job $_ -proxy $vProxyName }
$vcdJobs | % { Set-VBRJobOptions -Job $_ -Options $retention }
$vcdJobs | % { set-VBRJobSchedule -job $_ -Daily -At $RunTime }
$vcdJobs | % { Enable-VBRJobSchedule -job $_ }
All Together
Following those steps will get you started with the creating a Veeam vCD backup Job, and with customising some of the Backup Job Parameters.
Finally, let’s add a menu to the script where the Tenant can choose from the retention options. Of course, these retention options are defined by the Service Provider.
See the following for the Menu and the options:
function Show-Menu
{
param (
[string]$Title = ‘vCloud Director Self-Service Scripting Demo’
)
cls
Write-Host “=========================== $Title ============================”
Write-Host
Write-Host “1: Press ‘1’ for 10 Daily backups retained.”
Write-Host “2: Press ‘2’ for 20 Daily backups retained.”
Write-Host “3: Press ‘3’ for 30 Daily backups retained.”
Write-Host
Write-Host “======================================================================”
Write-Host “Q: Press ‘Q’ to quit.”
Write-Host “======================================================================”
}do
{
Now let’s define each retention:
{
$vCDSrvName = “Enter Your vCD Server Host Name “
$vBRRepoName = “Enter Your Repository Name”
$vProxyName = “Enter the Proxy Name if you wish to assign Proxy Manually”
$vCDOrgName = “Enter the Orgname”$vcdServer = get-vbrserver -name $vCDSrvName
$backupRepo = Get-VBRBackupRepository -name $vBRRepoName
$proxy = get-vbrviproxy -name $vProxyName
$vCDvApps = Find-VBRvCloudEntity -Server $vcdServer -vAppShow-Menu
$input = Read-Host “Please make a selection”
switch ($input)
{
‘1’ {
cls
$RunTime =”23:00″
$retention = New-VBRJobOptions -ForBackupJob
$retention.BackupStorageOptions.RetainCycles = 10$vCDvApps = $vCDvApps| ? { $_.Type -eq ‘vApp’ -and $_.Path -match $vCDOrgName }
$vcdJobs = $vCDvApps | % { Add-VBRvCloudJob -name “Enter Job Name – $($_.name)” -description “Enter the description of the Backup Job” -entity $_ -BackupRepository $vBRRepoName }$vcdJobs | % { set-vbrjobproxy -job $_ -proxy $vProxyName }
$vcdJobs | % { Set-VBRJobOptions -Job $_ -Options $retention }
$vcdJobs | % { set-VBRJobSchedule -job $_ -Daily -At $RunTime }
$vcdJobs | % { Enable-VBRJobSchedule -job $_ }Write-Host
‘You chose option #1 = 10 Daily backups retained.’
} ‘2’ {
cls
#Set Retention Policy
$retention = New-VBRJobOptions -ForBackupJob
$retention.BackupStorageOptions.RetainCycles = 20$vCDvApps = $vCDvApps| ? { $_.Type -eq ‘vApp’ -and $_.Path -match $vCDOrgName }
$vcdJobs = $vCDvApps | % { Add-VBRvCloudJob -name “Enter Job Name – $($_.name)” -description “Enter the description of the Backup Job” -entity $_ -BackupRepository $vBRRepoName }$vcdJobs | % { set-vbrjobproxy -job $_ -proxy $vProxyName }
$vcdJobs | % { Set-VBRJobOptions -Job $_ -Options $retention }
$vcdJobs | % { set-VBRJobSchedule -job $_ -Daily -At $RunTime }
$vcdJobs | % { Enable-VBRJobSchedule -job $_ }Write-Host
‘You chose option #1 = 20 Daily backups retained.’
} ‘3’ {
cls
#Set Retention Policy
$retention = New-VBRJobOptions -ForBackupJob
$retention.BackupStorageOptions.RetainCycles = 30
$vCDvApps = $vCDvApps| ? { $_.Type -eq ‘vApp’ -and $_.Path -match $vCDOrgName }
$vcdJobs = $vCDvApps | % { Add-VBRvCloudJob -name “Enter Job Name – $($_.name)” -description “Enter the description of the Backup Job” -entity $_ -BackupRepository $vBRRepoName }$vcdJobs | % { set-vbrjobproxy -job $_ -proxy $vProxyName }
$vcdJobs | % { Set-VBRJobOptions -Job $_ -Options $retention }
$vcdJobs | % { set-VBRJobSchedule -job $_ -Daily -At $RunTime }
$vcdJobs | % { Enable-VBRJobSchedule -job $_ }Write-Host
‘You chose option #1 = 30 Daily backups retained.’
} ‘q’ {
return
}
}
pause
}
until ($input -eq ‘q’)
Summary
The Veeam-vCD integration offers lots of automation and a self-service portal through the Veeam Enterprise Manager. Some service providers want to offer Veeam-vCD self-service while using their own portal and to do so. Service Providers can use RESTful and/or Powershell; on this blog, I have shown you how to use Veeam Powershell to accomplish the integration. I hope this blog post was easy to follow and informative.