使用 PowerShell 部署和管理 Data Protection Manager (DPM) 服务器的 Azure 备份Deploy and manage backup to Azure for Data Protection Manager (DPM) servers using PowerShell

本文说明如何使用 PowerShell 在 DPM 服务器上设置 Azure 备份,以及管理备份和恢复。This article shows you how to use PowerShell to setup Azure Backup on a DPM server, and to manage backup and recovery.

设置 PowerShell 环境Setting up the PowerShell environment

在可以使用 PowerShell 管理 Data Protection Manager 的 Azure 备份之前,需要在 PowerShell 中设置适当的环境。Before you can use PowerShell to manage backups from Data Protection Manager to Azure, you need to have the right environment in PowerShell. 在 PowerShell 会话开始时,请确保运行以下命令,以便导入正确的模块以及正确引用 DPM cmdlet:At the start of the PowerShell session, ensure that you run the following command to import the right modules and allow you to correctly reference the DPM cmdlets:

& "C:\Program Files\Microsoft System Center 2012 R2\DPM\DPM\bin\DpmCliInitScript.ps1"
Welcome to the DPM Management Shell!

Full list of cmdlets: Get-Command
Only DPM cmdlets: Get-DPMCommand
Get general help: help
Get help for a cmdlet: help <cmdlet-name> or <cmdlet-name> -?
Get definition of a cmdlet: Get-Command <cmdlet-name> -Syntax
Sample DPM scripts: Get-DPMSampleScript

设置和注册Setup and Registration

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

若要开始,请下载最新的 Azure PowerShellTo begin, download the latest Azure PowerShell.

使用 PowerShell 可以自动化以下设置和注册任务:The following setup and registration tasks can be automated with PowerShell:

  • 创建恢复服务保管库Create a Recovery Services vault
  • 安装 Azure 备份代理Installing the Azure Backup agent
  • 注册到 Azure 备份服务Registering with the Azure Backup service
  • 网络设置Networking settings
  • 加密设置Encryption settings

创建恢复服务保管库Create a recovery services vault

以下步骤引导用户创建恢复服务保管库。The following steps lead you through creating a Recovery Services vault. 恢复服务保管库不同于备份保管库。A Recovery Services vault is different than a Backup vault.

  1. 首次使用 Azure 备份时,必须使用 Register-AzResourceProvider cmdlet 将 Azure 恢复服务提供程序注册到订阅。If you are using Azure Backup for the first time, you must use the Register-AzResourceProvider cmdlet to register the Azure Recovery Service provider with your subscription.

    Register-AzResourceProvider -ProviderNamespace "Microsoft.RecoveryServices"
    
  2. 恢复服务保管库是一种 ARM 资源,因此需要将它放在资源组中。The Recovery Services vault is an ARM resource, so you need to place it within a Resource Group. 可以使用现有资源组,也可以创建新组。You can use an existing resource group, or create a new one. 创建新的资源组时,请指定资源组的名称和位置。When creating a new resource group, specify the name and location for the resource group.

    New-AzResourceGroup -Name "test-rg" -Location "China North"
    
  3. 使用 New-AzRecoveryServicesVault cmdlet 创建新的保管库。Use the New-AzRecoveryServicesVault cmdlet to create a new vault. 确保为保管库指定的位置与用于资源组的位置是相同的。Be sure to specify the same location for the vault as was used for the resource group.

    New-AzRecoveryServicesVault -Name "testvault" -ResourceGroupName " test-rg" -Location "China North"
    
  4. 指定要使用的存储冗余类型;可以使用本地冗余存储 (LRS)异地冗余存储 (GRS)Specify the type of storage redundancy to use; you can use Locally Redundant Storage (LRS) or Geo-redundant Storage (GRS). 以下示例显示,testVault 的 -BackupStorageRedundancy 选项设置为 GeoRedundant。The following example shows the -BackupStorageRedundancy option for testVault is set to GeoRedundant.

    提示

    许多 Azure 备份 cmdlet 要求使用恢复服务保管库对象作为输入。Many Azure Backup cmdlets require the Recovery Services vault object as an input. 因此,在变量中存储备份恢复服务保管库对象可提供方便。For this reason, it is convenient to store the Backup Recovery Services vault object in a variable.

    $vault1 = Get-AzRecoveryServicesVault -Name "testVault"
    Set-AzRecoveryServicesBackupProperties  -vault $vault1 -BackupStorageRedundancy GeoRedundant
    

在订阅中查看保管库View the vaults in a subscription

使用 Get-AzRecoveryServicesVault 查看当前订阅中所有保管库的列表。Use Get-AzRecoveryServicesVault to view the list of all vaults in the current subscription. 可以使用此命令来查看是否创建了新的保管库,或者查看订阅中的可用保管库。You can use this command to check that a new vault was created, or to see what vaults are available in the subscription.

运行 Get-AzRecoveryServicesVault 命令即可列出订阅中的所有保管库。Run the command, Get-AzRecoveryServicesVault, and all vaults in the subscription are listed.

Get-AzRecoveryServicesVault
Name              : Contoso-vault
ID                : /subscriptions/1234
Type              : Microsoft.RecoveryServices/vaults
Location          : ChinaNorth
ResourceGroupName : Contoso-docs-rg
SubscriptionId    : 1234-567f-8910-abc
Properties        : Microsoft.Azure.Commands.RecoveryServices.ARSVaultProperties

在 DPM 服务器上安装 Azure 备份代理Installing the Azure Backup agent on a DPM Server

在安装 Azure 备份代理之前,必须先将安装程序下载到 Windows Server 上。Before you install the Azure Backup agent, you need to have the installer downloaded and present on the Windows Server. 可以从 Microsoft 下载中心或恢复服务保管库的“仪表板”页获取最新版本的安装程序。You can get the latest version of the installer from the Microsoft Download Center or from the Recovery Services vault's Dashboard page. 将安装程序保存到方便访问的位置,例如 C:\Downloads\*Save the installer to an easily accessible location like C:\Downloads\*.

若要安装代理,请在 DPM 服务器上已提升权限的 PowerShell 控制台中运行以下命令:To install the agent, run the following command in an elevated PowerShell console on the DPM server:

MARSAgentInstaller.exe /q

这会以所有默认选项安装代理。This installs the agent with all the default options. 安装在几分钟内在后台完成。The installation takes a few minutes in the background. 如果没有指定 /nu 选项,则安装结束时,会打开“Windows Update”窗口,以检查是否有任何更新。If you do not specify the /nu option the Windows Update window opens at the end of the installation to check for any updates.

代理在已安装程序列表中显示。The agent shows up in the list of installed programs. 若要查看已安装的程序列表,请转到“控制面板”“ > 程序 > ”“程序和功能”。To see the list of installed programs, go to Control Panel > Programs > Programs and Features.

已安装代理

安装选项Installation options

若要查看可通过命令行使用的所有选项,请使用以下命令:To see all the options available via the command line, use the following command:

MARSAgentInstaller.exe /?

可用选项包括:The available options include:

选项Option 详细信息Details 默认Default
/q/q 静默安装Quiet installation -
/p:"location"/p:"location" Azure 备份代理的安装文件夹路径。Path to the installation folder for the Azure Backup agent. C:\Program Files\Microsoft Azure Recovery Services AgentC:\Program Files\Microsoft Azure Recovery Services Agent
/s:"location"/s:"location" Azure 备份代理的缓存文件夹路径。Path to the cache folder for the Azure Backup agent. C:\Program Files\Microsoft Azure Recovery Services Agent\ScratchC:\Program Files\Microsoft Azure Recovery Services Agent\Scratch
/m/m 选择启用 Microsoft UpdateOpt-in to Microsoft Update -
/nu/nu 安装完成后不要检查更新Do not Check for updates after installation is complete -
/d/d 卸载 Microsoft Azure 恢复服务代理Uninstalls Microsoft Azure Recovery Services Agent -
/ph/ph 代理主机地址Proxy Host Address -
/po/po 代理主机端口号Proxy Host Port Number -
/pu/pu 代理主机用户名Proxy Host UserName -
/pw/pw 代理密码Proxy Password -

将 DPM 注册到恢复服务保管库Registering DPM to a Recovery Services Vault

创建恢复服务保管库后,请下载最新的代理和保管库凭据,并将其存储在一个方便访问的位置(如 C:\Downloads)。After you created the Recovery Services vault, download the latest agent and the vault credentials and store it in a convenient location like C:\Downloads.

$credspath = "C:\downloads"
$credsfilename = Get-AzRecoveryServicesVaultSettingsFile -Backup -Vault $vault1 -Path  $credspath
$credsfilename
C:\downloads\testvault\_Sun Apr 10 2016.VaultCredentials

在 DPM 服务器上,运行 Start-OBRegistration cmdlet,将计算机注册到保管库。On the DPM server, run the Start-OBRegistration cmdlet to register the machine with the vault.

$cred = $credspath + $credsfilename
Start-OBRegistration-VaultCredentials $cred -Confirm:$false
CertThumbprint      :7a2ef2caa2e74b6ed1222a5e89288ddad438df2
SubscriptionID      : ef4ab577-c2c0-43e4-af80-af49f485f3d1
ServiceResourceName: testvault
Region              :China North
Machine registration succeeded.

初始配置设置Initial configuration settings

DPM 服务器在注册到恢复服务保管库后,会使用默认的订阅设置启动。Once the DPM Server is registered with the Recovery Services vault, it starts with default subscription settings. 这些订阅设置包括网络、加密和临时区域。These subscription settings include Networking, Encryption and the Staging area. 若要更改订阅设置,需要先使用 Get-DPMCloudSubscriptionSetting cmdlet 获取现有(默认)设置中的句柄:To change subscription settings you need to first get a handle on the existing (default) settings using the Get-DPMCloudSubscriptionSetting cmdlet:

$setting = Get-DPMCloudSubscriptionSetting -DPMServerName "TestingServer"

所有修改都会对此本地 PowerShell 对象 $setting 进行,然后使用 Set-DPMCloudSubscriptionSetting cmdlet 将整个对象提交到 DPM 和 Azure 备份以进行保存。All modifications are made to this local PowerShell object $setting and then the full object is committed to DPM and Azure Backup to save them using the Set-DPMCloudSubscriptionSetting cmdlet. 需要使用 -Commit 标志来确保持久保存所做的更改。You need to use the -Commit flag to ensure that the changes are persisted. 除非已提交,否则 Azure 备份不会应用和使用这些设置。The settings will not be applied and used by Azure Backup unless committed.

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -Commit

网络Networking

如果 DPM 计算机与 Internet 上 Azure 备份服务的连接是通过代理服务器建立的,则只有提供代理服务器设置,才能成功备份。If the connectivity of the DPM machine to the Azure Backup service on the internet is through a proxy server, then the proxy server settings should be provided for successful backups. 为此,可以结合 -ProxyServer-ProxyPort-ProxyUsernameProxyPassword 参数使用 Set-DPMCloudSubscriptionSetting cmdlet。This is done by using the -ProxyServerand -ProxyPort, -ProxyUsername and the ProxyPassword parameters with the Set-DPMCloudSubscriptionSetting cmdlet. 此示例未使用代理服务器,因此我们要显式清除任何代理相关的信息。In this example, there is no proxy server so we are explicitly clearing any proxy-related information.

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -NoProxy

也可针对给定的一组星期日期,使用 -WorkHourBandwidth-NonWorkHourBandwidth 选项来控制带宽使用。Bandwidth usage can also be controlled with options of -WorkHourBandwidth and -NonWorkHourBandwidth for a given set of days of the week. 本示例未设置任何限制。In this example, we are not setting any throttling.

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -NoThrottle

配置过渡区域Configuring the staging Area

在 DPM 服务器上运行的 Azure 备份代理需要使用临时存储来存放从云还原的数据(本地过渡区域)。The Azure Backup agent running on the DPM server needs temporary storage for data restored from the cloud (local staging area). 可以使用 Set-DPMCloudSubscriptionSetting cmdlet 和 -StagingAreaPath 参数来配置过渡区域。Configure the staging area using the Set-DPMCloudSubscriptionSetting cmdlet and the -StagingAreaPath parameter.

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -StagingAreaPath "C:\StagingArea"

在上述示例中,在 PowerShell 对象 $setting 中将暂存区域设置为 C:\StagingAreaIn the example above, the staging area will be set to C:\StagingArea in the PowerShell object $setting. 请确保指定的文件夹已存在,否则订阅设置的最终提交会失败。Ensure that the specified folder already exists, or else the final commit of the subscription settings will fail.

加密设置Encryption settings

发送到 Azure 备份的备份数据会加密,以保护数据的机密性。The backup data sent to Azure Backup is encrypted to protect the confidentiality of the data. 加密通行短语是在还原时用于解密数据的“密码”。The encryption passphrase is the "password" to decrypt the data at the time of restore. 必须妥善保管设置好的通行短语,并保证其安全。It is important to keep this information safe and secure once it is set.

在以下示例中,第一个命令会将字符串 passphrase123456789 转换为安全字符串,并将安全字符串分配给名为 $Passphrase 的变量。In the example below, the first command converts the string passphrase123456789 to a secure string and assigns the secure string to the variable named $Passphrase. 第二个命令会将 $Passphrase 中的安全字符串设置为加密备份的密码。the second command sets the secure string in $Passphrase as the password for encrypting backups.

$Passphrase = ConvertTo-SecureString -string "passphrase123456789" -AsPlainText -Force

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -EncryptionPassphrase $Passphrase

重要

请妥善保管设置好的通行短语,并保证其安全。Keep the passphrase information safe and secure once it is set. 如果没有此通行短语,则无法从 Azure 还原数据。You will not be able to restore data from Azure without this passphrase.

此时,应该已对 $setting 对象做出了全部所需的更改。At this point, you should have made all the required changes to the $setting object. 请记得提交更改。Remember to commit the changes.

Set-DPMCloudSubscriptionSetting -DPMServerName "TestingServer" -SubscriptionSetting $setting -Commit

在 Azure 备份中保护数据Protect data to Azure Backup

本部分中需要将生产服务器添加到 DPM,并分别在本地 DPM 存储和 Azure 备份中保护数据。In this section, you will add a production server to DPM and then protect the data to local DPM storage and then to Azure Backup. 在示例中,我们演示如何备份文件和文件夹。In the examples, we will demonstrate how to back up files and folders. 可以轻松地延伸这种思路,以备份 DPM 支持的任何数据源。The logic can easily be extended to backup any DPM-supported data source. 所有 DPM 备份均受保护组 (PG) 控制,该组由四个部分构成:All your DPM backups are governed by a Protection Group (PG) with four parts:

  1. 组成员是要在相同保护组中保护的所有可保护对象的列表(在 DPM 中也称为数据源)。Group members is a list of all the protectable objects (also known as Datasources in DPM) that you want to protect in the same protection group. 例如,你可能想要保护一个保护组中的生产 VM 与另一个保护组中的 SQL Server 数据库,因为它们可能有不同的备份要求。For example, you may want to protect production VMs in one protection group and SQL Server databases in another protection group as they may have different backup requirements. 在可以备份生产服务器上的任何数据源之前,需要确保 DPM 代理已安装在服务器上并受 DPM 的管理。Before you can back up any datasource on a production server you need to make sure the DPM Agent is installed on the server and is managed by DPM. 执行安装 DPM 代理的步骤,并将代理链接到相应的 DPM 服务器。Follow the steps for installing the DPM Agent and linking it to the appropriate DPM Server.
  2. 数据保护方法 指定目标备份位置 - 磁带、磁盘和云。Data protection method specifies the target backup locations - tape, disk, and cloud. 在本示例中,我们会在本地磁盘和云中保护数据。In our example we will protect data to the local disk and to the cloud.
  3. 备份计划 ,用于指定需要进行备份的时间,以及应该在 DPM 服务器和生产服务器之间同步数据的频率。A backup schedule that specifies when backups need to be taken and how often the data should be synchronized between the DPM Server and the production server.
  4. 保留计划 ,用于指定要在 Azure 中保留恢复点的时长。A retention schedule that specifies how long to retain the recovery points in Azure.

创建保护组Creating a protection group

首先,使用 New-DPMProtectionGroup cmdlet 创建新的保护组。Start by creating a new Protection Group using the New-DPMProtectionGroup cmdlet.

$PG = New-DPMProtectionGroup -DPMServerName " TestingServer " -Name "ProtectGroup01"

上述 cmdlet 将创建名为 ProtectGroup01 的保护组。The above cmdlet will create a Protection Group named ProtectGroup01. 也可以稍后修改现有的保护组,以将备份添加到 Azure 云中。An existing protection group can also be modified later to add backup to the Azure cloud. 不过,若要对保护组(新的或现有的)进行任何更改,我们需要使用 Get-DPMModifiableProtectionGroup cmdlet 来获取 modifiable 对象上的句柄。However, to make any changes to the Protection Group - new or existing - we need to get a handle on a modifiable object using the Get-DPMModifiableProtectionGroup cmdlet.

$MPG = Get-ModifiableProtectionGroup $PG

将组成员添加到保护组Adding group members to the Protection Group

每个 DPM 代理知道它安装所在服务器上数据源列表。Each DPM Agent knows the list of datasources on the server that it is installed on. 要将数据源添加到保护组,DPM 代理需要先将数据源列表发回给 DPM 服务器。To add a datasource to the Protection Group, the DPM Agent needs to first send a list of the datasources back to the DPM server. 然后选择一个或多个数据源,并将其添加到保护组。One or more datasources are then selected and added to the Protection Group. 实现此目的需要执行的 PowerShell 步骤包括:The PowerShell steps needed to achieve this are:

  1. 通过 DPM 代理获取 DPM 管理的所有服务器的列表。Fetch a list of all servers managed by DPM through the DPM Agent.
  2. 选择特定的服务器。Choose a specific server.
  3. 获取该服务器上所有数据源的列表。Fetch a list of all datasources on the server.
  4. 选择一个或多个数据源,并将其添加到保护组Choose one or more datasources and add them to the Protection Group

使用 Get-DPMProductionServer cmdlet 获取安装 DPM 代理并由 DPM 服务器管理的服务器的列表。The list of servers on which the DPM Agent is installed and is being managed by the DPM Server is acquired with the Get-DPMProductionServer cmdlet. 在本示例中,我们进行筛选,并只为备份配置名为 productionserver01 的 PS。In this example we will filter and only configure PS with name productionserver01 for backup.

$server = Get-ProductionServer -DPMServerName "TestingServer" | Where-Object {($_.servername) -contains "productionserver01"}

现在使用 Get-DPMDatasource cmdlet 获取 $server 上的数据源列表。Now fetch the list of datasources on $server using the Get-DPMDatasource cmdlet. 在本示例中,我们将筛选要为备份配置的卷 D:\In this example we are filtering for the volume D:\ that we want to configure for backup. 然后,使用 Add-DPMChildDatasource cmdlet 将此数据源添加到保护组。This datasource is then added to the Protection Group using the Add-DPMChildDatasource cmdlet. 请记得使用 modifiable 保护组对象 $MPG 来完成添加。Remember to use the modifiable protection group object $MPG to make the additions.

$DS = Get-Datasource -ProductionServer $server -Inquire | Where-Object { $_.Name -contains "D:\" }

Add-DPMChildDatasource -ProtectionGroup $MPG -ChildDatasource $DS

视需要重复此步骤多次,直到已将选择的所有数据源添加到保护组。Repeat this step as many times as required, until you have added all the chosen datasources to the protection group. 你也可以只从一个数据源开始,完成创建保护组的工作流,然后将更多的数据源添加到保护组。You can also start with just one datasource, and complete the workflow for creating the Protection Group, and at a later point add more datasources to the Protection Group.

选择数据保护方法Selecting the data protection method

将数据源添加到保护组后,下一步是使用 Set-DPMProtectionType cmdlet 指定保护方法。Once the datasources have been added to the Protection Group, the next step is to specify the protection method using the Set-DPMProtectionType cmdlet. 在本示例中,为本地磁盘和云备份设置保护组。In this example, the Protection Group is setup for local disk and cloud backup. 还需使用带 -Online 标志的 Add-DPMChildDatasource cmdlet 指定想要将其送到云中进行保护的数据源。You also need to specify the datasource that you want to protect to cloud using the Add-DPMChildDatasource cmdlet with -Online flag.

Set-DPMProtectionType -ProtectionGroup $MPG -ShortTerm Disk -LongTerm Online
Add-DPMChildDatasource -ProtectionGroup $MPG -ChildDatasource $DS -Online

设置保留范围Setting the retention range

使用 Set-DPMPolicyObjective cmdlet 设置备份点保留。Set the retention for the backup points using the Set-DPMPolicyObjective cmdlet. 尽管在定义备份计划之前设置保留点看起来有点奇怪,但使用 Set-DPMPolicyObjective cmdlet 会自动设置稍后可修改的默认备份计划。While it might seem odd to set the retention before the backup schedule has been defined, using the Set-DPMPolicyObjective cmdlet automatically sets a default backup schedule that can then be modified. 始终可以先设置备份计划,再设置保留策略。It is always possible to set the backup schedule first and the retention policy after.

以下示例中的 cmdlet 将设置磁盘备份的保留参数。In the example below, the cmdlet sets the retention parameters for disk backups. 这会将备份保留 10 天,并每隔 6 小时在生产服务器和 DPM 服务器之间同步数据。This will retain backups for 10 days, and sync data every 6 hours between the production server and the DPM server. SynchronizationFrequencyMinutes 不会定义创建备份点的频率,只会定义数据复制到 DPM 服务器的频率。The SynchronizationFrequencyMinutes doesn't define how often a backup point is created, but how often data is copied to the DPM server. 此设置可防止备份变得太大。This setting prevents backups from becoming too large.

Set-DPMPolicyObjective -ProtectionGroup $MPG -RetentionRangeInDays 10 -SynchronizationFrequencyMinutes 360

为了将备份转移到 Azure(DPM 将此称为联机备份),可将保留期配置为使用祖父-父-子方案 (GFS) 的长期保留For backups going to Azure (DPM refers to them as Online backups) the retention ranges can be configured for long term retention using a Grandfather-Father-Son scheme (GFS). 也就是说,可以定义组合保留策略,其中包括每日、每周、每月和每年保留策略。That is, you can define a combined retention policy involving daily, weekly, monthly and yearly retention policies. 在此示例中,我们将创建一个用于表示所需复杂保留配置的数组,并使用 Set-DPMPolicyObjective cmdlet 配置保留范围。In this example, we create an array representing the complex retention scheme that we want, and then configure the retention range using the Set-DPMPolicyObjective cmdlet.

$RRlist = @()
$RRList += (New-Object -TypeName Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.RetentionRange -ArgumentList 180, Days)
$RRList += (New-Object -TypeName Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.RetentionRange -ArgumentList 104, Weeks)
$RRList += (New-Object -TypeName Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.RetentionRange -ArgumentList 60, Month)
$RRList += (New-Object -TypeName Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.RetentionRange -ArgumentList 10, Years)
Set-DPMPolicyObjective -ProtectionGroup $MPG -OnlineRetentionRangeList $RRlist

设置备份计划Set the backup schedule

如果使用 Set-DPMPolicyObjective cmdlet 指定保护目标,DPM 会自动设置默认的备份计划。DPM sets a default backup schedule automatically if you specify the protection objective using the Set-DPMPolicyObjective cmdlet. 若要更改默认计划,请依序使用 Get-DPMPolicySchedule cmdlet 和 Set-DPMPolicySchedule cmdlet。To change the default schedules, use the Get-DPMPolicySchedule cmdlet followed by the Set-DPMPolicySchedule cmdlet.

$onlineSch = Get-DPMPolicySchedule -ProtectionGroup $mpg -LongTerm Online
Set-DPMPolicySchedule -ProtectionGroup $MPG -Schedule $onlineSch[0] -TimesOfDay 02:00
Set-DPMPolicySchedule -ProtectionGroup $MPG -Schedule $onlineSch[1] -TimesOfDay 02:00 -DaysOfWeek Sa,Su -Interval 1
Set-DPMPolicySchedule -ProtectionGroup $MPG -Schedule $onlineSch[2] -TimesOfDay 02:00 -RelativeIntervals First,Third -DaysOfWeek Sa
Set-DPMPolicySchedule -ProtectionGroup $MPG -Schedule $onlineSch[3] -TimesOfDay 02:00 -DaysOfMonth 2,5,8,9 -Months Jan,Jul
Set-DPMProtectionGroup -ProtectionGroup $MPG

在上例中,$onlineSch 是带有四个元素的数组,其中包含采用 GFS 方案的保护组的现有联机保护计划:In the above example, $onlineSch is an array with four elements that contains the existing online protection schedule for the Protection Group in the GFS scheme:

  1. $onlineSch[0] 包含每日计划$onlineSch[0] contains the daily schedule
  2. $onlineSch[1] 包含每周计划$onlineSch[1] contains the weekly schedule
  3. $onlineSch[2] 包含每月计划$onlineSch[2] contains the monthly schedule
  4. $onlineSch[3] 包含每年计划$onlineSch[3] contains the yearly schedule

因此,如果需要修改每周计划,需要引用 $onlineSch[1]So if you need to modify the weekly schedule, you need to refer to the $onlineSch[1].

初始备份Initial backup

第一次备份数据源时,DPM 需要创建初始副本,该初始副本用于创建要在 DPM 副本卷上保护的数据源的完整副本。When backing up a datasource for the first time, DPM needs creates initial replica that creates a full copy of the datasource to be protected on DPM replica volume. 此活动可以安排在特定的时间,或使用 Set-DPMReplicaCreationMethod cmdlet 并结合参数 -NOW 手动触发。This activity can either be scheduled for a specific time, or can be triggered manually, using the Set-DPMReplicaCreationMethod cmdlet with the parameter -NOW.

Set-DPMReplicaCreationMethod -ProtectionGroup $MPG -NOW

更改 DPM 副本和恢复点卷的大小Changing the size of DPM Replica & recovery point volume

此外可以使用 Set-dpmdatasourcediskallocation cmdlet 更改 DPM 副本卷和影子副本卷的大小,如以下示例所示:Get-DatasourceDiskAllocation -Datasource $DS Set-DatasourceDiskAllocation -Datasource $DS -ProtectionGroup $MPG -manual -ReplicaArea (2gb) -ShadowCopyArea (2gb)You can also change the size of DPM Replica volume and Shadow Copy volume using Set-DPMDatasourceDiskAllocation cmdlet as in the following example: Get-DatasourceDiskAllocation -Datasource $DS Set-DatasourceDiskAllocation -Datasource $DS -ProtectionGroup $MPG -manual -ReplicaArea (2gb) -ShadowCopyArea (2gb)

将更改提交到保护组Committing the changes to the Protection Group

最后,需要提交更改,DPM 才可以根据每个新保护组配置进行备份。Finally, the changes need to be committed before DPM can take the backup per the new Protection Group configuration. 这可以使用 Set-DPMProtectionGroup cmdlet 来实现。This can be achieved using the Set-DPMProtectionGroup cmdlet.

Set-DPMProtectionGroup -ProtectionGroup $MPG

查看备份点View the backup points

可以使用 Get-DPMRecoveryPoint cmdlet 来获取数据源的所有恢复点列表。You can use the Get-DPMRecoveryPoint cmdlet to get a list of all recovery points for a datasource. 在本示例中,我们将:In this example, we will:

  • 获取 DPM 服务器上的和存储在数组 $PGfetch all the PGs on the DPM server and stored in an array $PG
  • 获取对应于 $PG[0]get the datasources corresponding to the $PG[0]
  • 获取数据源的所有恢复点。get all the recovery points for a datasource.
$PG = Get-DPMProtectionGroup -DPMServerName "TestingServer"
$DS = Get-DPMDatasource -ProtectionGroup $PG[0]
$RecoveryPoints = Get-DPMRecoverypoint -Datasource $DS[0] -Online

还原 Azure 上受保护的数据Restore data protected on Azure

还原数据是 RecoverableItem 对象和 RecoveryOption 对象的组合结果。Restoring data is a combination of a RecoverableItem object and a RecoveryOption object. 在上一部分中,我们已获取数据源的备份点列表。In the previous section, we got a list of the backup points for a datasource.

在以下示例中,我们演示如何通过组合备份点与恢复目标,从 Azure 备份还原 Hyper-V 虚拟机。In the example below, we demonstrate how to restore a Hyper-V virtual machine from Azure Backup by combining backup points with the target for recovery. 此示例包括:This example includes:

  • 使用 New-DPMRecoveryOption cmdlet 创建恢复选项。Creating a recovery option using the New-DPMRecoveryOption cmdlet.
  • 使用 Get-DPMRecoveryPoint cmdlet 获取备份点的数组。Fetching the array of backup points using the Get-DPMRecoveryPoint cmdlet.
  • 选择要从中还原的备份点。Choosing a backup point to restore from.
$RecoveryOption = New-DPMRecoveryOption -HyperVDatasource -TargetServer "HVDCenter02" -RecoveryLocation AlternateHyperVServer -RecoveryType Recover -TargetLocation "C:\VMRecovery"

$PG = Get-DPMProtectionGroup -DPMServerName "TestingServer"
$DS = Get-DPMDatasource -ProtectionGroup $PG[0]
$RecoveryPoints = Get-DPMRecoverypoint -Datasource $DS[0] -Online

Restore-DPMRecoverableItem -RecoverableItem $RecoveryPoints[0] -RecoveryOption $RecoveryOption

可针对任何数据源类型轻松扩展这些命令。The commands can easily be extended for any datasource type.