Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Backup de una máquina virtual Azure

1 min read

Backup de una máquina virtual Azure VM

En este artículo se muestra como usar algunos cmdlets de Azure PowerShell para realizar backup de una máquina virtual Azure (VM).

Con el fin de utilizar PowerShell de manera eficiente, es necesario entender la jerarquía de objetos y desde dónde empezar.

object-hierarchy-wikiazure

Pasos:

  1. Setup and Registration
  2. Create a backup vault
  3. Registering the VMs
  4. Backup Azure VMs
    1. Create a protection policy
    2. Enable protection
    3. Initial backup

Backup de una máquina virtual Azure VM

#************************
# Backup de una máquina virtual Azure 
# Author:@DaveRndn
#***********************

#**********************
# Variables
#********************
$location = "West US"
$AzureRmResourceGroupName = "BackupDemo2"
$ResourceGroupName = "BackupDemo2"
$backupvaultName = “test-vault2”

#Find cmdlets available
#Get-Command *azurermbackup*
Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.Backup"
#create a new backup vault and place it within a Resource Group.
New-AzureRmResourceGroup –Name $AzureRmResourceGroupName –Location $location
$backupvault = New-AzureRmBackupVault –ResourceGroupName $ResourceGroupName –Name $backupvaultName –Region $location –Storage GeoRedundant

#get a list of all the backup vaults in a given subscription using the Get-AzureRmBackupVault cmdlet
##Backup Azure VMs 
##########
#  Registering the VMs
#########
$registerjob = Register-AzureRmBackupContainer -Vault $backupvault -Name "testmyvm" -ServiceName "testmyvm"
# create protection  policy
Get-AzureRmBackupProtectionPolicy -Vault $backupvault
#define when and how often the backup of an item is done.
$Daily = New-AzureRmBackupRetentionPolicyObject -DailyRetention -Retention 30
$newpolicy = New-AzureRmBackupProtectionPolicy -Name DailyBackup01 -Type AzureVM -Daily -BackupTime ([datetime]"3:30 PM") -RetentionPolicy $Daily -Vault $backupvault
#Enable Protection
Get-AzureRmBackupContainer -Type AzureVM -Status Registered -Vault $backupvault | Get-AzureRmBackupItem | Enable-AzureRmBackupProtection -Policy $newpolicy
#Initial Backup
$container = Get-AzureRmBackupContainer -Vault $backupvault -Type AzureVM -Name "testmyvm"
$backupjob = Get-AzureRmBackupItem -Container $container | Backup-AzureRmBackupItem
$backupjob
#Note:The timezone of the StartTime and EndTime fields shown in PowerShell is UTC. 



Si estás buscando realizar el backup de máquinas como Windows Server, consulta el artículo de PowerShell para la protección de Windows Server, desplegar y gestionar copias de seguridad de Windows Server. También hay un artículo de PowerShell para administrar las copias de seguridad de DPM, desplegar y gestionar copias de seguridad de DPM.

Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Leave a Reply

Your email address will not be published. Required fields are marked *