Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# set empty backup policy object
PS C:\Users\Administrator> $Policy = New-WBPolicy
# add current system state to the backup policy
PS C:\Users\Administrator> Add-WBSystemState -Policy $Policy
# add baremetal revovery to the backup policy
PS C:\Users\Administrator> Add-WBBareMetalRecovery -Policy $Policy
# add source files/folders/volumes to take backup to the backup policy
# example follows specifies C dirive all
PS C:\Users\Administrator> New-WBFileSpec -FileSpec "C:" | Add-WBFileSpec -Policy $Policy
# if multiple drives exist, possible to add
PS C:\Users\Administrator> New-WBFileSpec -FileSpec "D:" | Add-WBFileSpec -Policy $Policy
# set Volume Shadow Copy Service (VSS) option to the backup policy
PS C:\Users\Administrator> Set-WBVssBackupOptions -Policy $Policy -VssCopyBackup
# set backup tagret Path
# example below specifies remote shared folder
# -NetworkPath (remote shared folder)
# -Credential (PSCredential for shared folder)
# specify a user who can access to shared and also who has wirte privilege to it
# example follows specifies a user/password [Serverworld/P@ssw0rd01]
PS C:\Users\Administrator> $BackupLocation = New-WBBackupTarget -NetworkPath "\\10.0.0.102\Share01" `
-Credential (New-Object PSCredential("Serverworld", (ConvertTo-SecureString -AsPlainText "P@ssw0rd01" -Force)))
# add backup tagret to the backup policy
PS C:\Users\Administrator> Add-WBBackupTarget -Policy $Policy -Target $BackupLocation
WARNING: The backed up data cannot be securely protected at this destination. Backups stored on a remote shared folder might be
accessible by other people on the network. You should only save your backups to a location where you trust the other users who
have access to the location or on a network that has additional security precautions in place.
WARNING: Backup or recovery of individual files or application data from DVDs or other removable media is not supported. You
can only backup or recover full volumes from this media.
type.
Label :
WBDisk :
WBVolume :
Path : \\10.0.0.102\Share01
TargetType : Network
InheritAcl : True
PreserveExistingBackup : False
# confirm configured backup policy
PS C:\Users\Administrator> $Policy
Schedule :
BackupTargets : {\\10.0.0.102\Share01}
VolumesToBackup :
FilesSpecsToBackup : {C:*}
FilesSpecsToExclude : {}
ComponentsToBackup :
BMR : True
SystemState : True
OverwriteOldFormatVhd : False
VssBackupOptions : VssCopyBackup
# run backup
PS C:\Users\Administrator> Start-WBBackup -Policy $Policy
Initializing the list of items to be backed up...
Volume 1 (0%) of 3 volume(s).
Volume 1 (0%) of 3 volume(s).
Volume 1 (100%) of 3 volume(s).
Volume 2 (1%) of 3 volume(s).
.....
.....
Volume 2 (96%) of 3 volume(s).
Volume 2 (97%) of 3 volume(s).
Volume 3 (63%) of 3 volume(s).
The backup operation completed.
# confirm backup history
PS C:\Users\Administrator> Get-WBSummary
NextBackupTime : 1/1/0001 12:00:00 AM
NumberOfVersions : 1
LastSuccessfulBackupTime : 12/21/2022 8:46:53 PM
LastSuccessfulBackupTargetPath : \\10.0.0.102\Share01
LastSuccessfulBackupTargetLabel :
LastBackupTime : 12/21/2022 8:46:53 PM
LastBackupTarget : \\10.0.0.102\Share01
DetailedMessage :
LastBackupResultHR : 0
LastBackupResultDetailedHR : 0
CurrentOperationStatus : NoOperationInProgress
|