欢迎来到我的的博客园,祝大家学有所成,早点实现自己的人生理想。

世纪互联提供的关于Powershell中将虚拟机加入备份保管库的方法

 请您参考以下步骤进行操作,如有问题请与我们联系:

 

  1. 对一台ARM虚拟机(虚拟机名称:paularm08r21)进行备份(参考:https://www.azure.cn/documentation/articles/backup-azure-vms-automation/

l  使用的Azure PowerShell 命令(修改标黄内容即可):

============================

#设置要使用的备份保管库上下文

Get-AzureRmRecoveryServicesVault -Name paulrmvault01 | Set-AzureRmRecoveryServicesVaultContext

#创建一条备份保护策略

$schPol = Get-AzureRmRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureVM"

$retPol = Get-AzureRmRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM"

New-AzureRmRecoveryServicesBackupProtectionPolicy -Name paularmpolicy -WorkloadType AzureVM -RetentionPolicy $retPol -SchedulePolicy $schPol

#修改这条备份保护策略(下例是禁用周、月、年备份)

$retPol = Get-AzureRmRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM"

$retPol.IsWeeklyScheduleenabled = $false

$retPol.IsMonthlyScheduleenabled = $false

$retPol.IsYearlyScheduleenabled = $false

$pol= Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name paularmpolicy

Set-AzureRmRecoveryServicesBackupProtectionPolicy -Policy $pol  -RetentionPolicy  $retPol

#使用上面创建的备份包含策略启用一台虚拟机备份

$pol=Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name paularmpolicy

Enable-AzureRmRecoveryServicesBackupProtection -Policy $pol -Name paularm08r21 -ResourceGroupName paularmnorth

#初始化(立即)这台虚拟机的备份工作

$namedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType "AzureVM" -Status "Registered" -Name paularm08r21

$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM"

$job = Backup-AzureRmRecoveryServicesBackupItem -Item $item

#查看当前的备份进度

$joblist = Get-AzureRmRecoveryservicesBackupJob -Status InProgress

$joblist[0]

============================

posted @ 2017-01-17 10:50  宋兴柱  阅读(487)  评论(0编辑  收藏  举报