In the past few versions of Windows Server, Microsoft has increased R & D investment in PowerShell tools to make them available flexibly. In Windows Server 2008 R2 and Windows Server 2012, you can use PowerShell to create a backup that can be used for bare metal recovery. In this article, we will discuss how to operate.
Although it is not necessary to back up bare metal recovery using PowerShell, Microsoft claims that PowerShell is a Windows Server Management Interface recommended by Microsoft, and the traditional graphic-based management method will eventually become a thing of the past. Therefore, system administrators need to master PowerShell to avoid being eliminated by the times.
Recovery Operations for different applications are also different. This document mainly targets backup applications on Windows servers. Of course, some other backup manufacturers also support command line backup operations, but the commands provided by different manufacturers are also different.
Therefore, you need to make some preparations on Windows Server to install the BACKUP command on Windows Server to PowerShell:
In Windows Server 2012, the required PowerShell module is automatically loaded. However, if Windows Server 2008 R2 is used, run the All Modules command to load the required module components.
Increase bare metal recovery capability
The Windows backup policy specifies whether bare metal backup can be created or restored. Therefore, you must first determine whether such a policy exists. You can run the Get-WBPolicy cmdlet command.
If the related Windows backup policy is not displayed, you need to create one. Run the New-WBPolicy cmdlet.
Once a Windows backup policy is created, you must modify the policy to allow bare metal recovery. To make this change, you must be an administrator group or a member of the backup operator group. In addition, before modification, the policy must be set to changeable.
If the New-WBPolicy cmdlet has just been created, the New policy should display a changeable status. If not, you need to add the-editable suffix after the Get-WBPolicy cmdlet command as the parameter.
Once the Windows backup policy is marked as editable, you can use the Add-WBBareMetalRecovery cmdlet to Add bare metal recovery for this policy. During the operation, you also need to add the-policy suffix to specify the corresponding windows backup policy. Generally, the command format is written as follows:
- Add-WBBareMetalRecovery –Policy $policy
After adding the bare metal recovery function to the Windows backup policy, you also need to confirm whether the operation is successful. The most convenient way is to use the Get-WBBareMetalRecovery cmdlet command to check whether the policy contains the bare metal recovery function. The command format is as follows:
- Get-WBBareMetalRecovery –Policy $policy
After a policy is created, it is especially convenient to use. You can run the Start-WBBackup cmdlet to complete the backup operation. Simply tell Windows that you want to use the policy you created earlier.
Generally, you also need to specify the backup location, which is basically specified through the New-WBBackupTarget cmdlet command. After the backup is completed, use this command to specify the target location of the backup. For example, you can use the following command to specify a backup target:
- $BackupLocation = New=WBBackupTarget –VolumePath E:
-
- Add-WBBackupTarget –Policy $Policy –Target $BackupLocation
Once the backup target is specified, the backup process can be started. You can execute the following command:
- Start-WBBackup –Policy $policy
Although a backup operation has been manually created by this command, the scheduled backup plan can also be easily completed.
Merge these operations
Although we have introduced different command usage methods, I still want to combine these backup creation policies, bare metal recovery, and backup initiation operations. For specific commands, see the following example:
- $policy = New-WBpolicy
-
- Add-WBBareMetalRecovery $policy
-
- $BackupLocation = New-WBBackupTarget –VolumePath E:
-
- Add-WBBackupTarget –Policy $Policy –Target $BackupLocation
-
- Start-WBBackup –Policy $policy
This article describes how to use PowerShell to create a backup that can be used for bare metal recovery. You can also use similar techniques to implement other types of backup. The Add-WBVolume, Add-WBFileSpec, and Add-WBSystemState functions in Cmdlets can be used to create other types of backups.