#Azure Backup quickly protect your VMs with powershell #OMS


Now that Azure Backup can be automated using powershell it’s super easy to create a backup vault and start protecting your virtual machines.

...
switch-azuremode AzureResourceManager
$rgname='eCloud-Infra'
New-AzureResourceGroup –Name $rgname -Location westeurope
$backupvault = New-AzureRMBackupVault –ResourceGroupName $rgname –Name 'Infra-Vault' –Storage LocallyRedundant -Region westeurope
#Daily backup with 10 days retention
$newpolicy = New-AzureRMBackupProtectionPolicy -Name Daily10 -Type AzureVM -Daily -BackupTime ([datetime]"11:30 PM") -RetentionPolicy ($Daily) -Vault $backupvault
#get all the v1 VMs in curent Subscription
$vms = AzureGet-AzureVM
$registerJobs=@()
foreach($vm in $vms) {
    if(Get-AzureRMBackupContainer -Vault $backupVault -Type AzureVM -Name $vm.Name -Status NotRegistered) {
        $registerjobs += Register-AzureRMBackupContainer -Vault $backupvault -Name $vm.Name -ServiceName $vm.ServiceName
    }
}
#we can wait on jobs
#$registerJobs | Wait-AzureRMBackupJob
#we can check the results
Get-AzureRMBackupContainer -Vault $backupVault -Type AzureVM

Known bugs and limitations:
– you cannot protect v2 Virtual Machines (i.e. ARM deployed VMs)
– the current powershell module (0.9.8) has a bug with mixed case virtual machines
– the current powershell module (0.9.8) has bug where it doesn’t return the backup jobs on systems with with non ENU locale

More info

-Daniele
This posting is provided “AS IS” with no warranties, and confers no rights.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: