by admin » Sun Mar 06, 2011 12:13 am
1.) Enable Windows PowerShell Support for Windows Server Backup
Import-Module ServerManager
Add-WindowsFeature Backup-Features -Include
Add-PSSnapin Windows.ServerBackup
2.) Create /Get/Edit Policy (Schedule)
The backup is controlled by the WBPolicy. This policy includes all the information necessary to perform a backup, including the backup schedule. You can create a new policy, retrieve an existing policy, or open an existing policy in edit mode to change it.
$BPol = Get-WBPolicy
$BPol = Get-WBPolicy -edit
$BPol = New-WBPolicy
3.) Include Volumes in the Backup
Create individual WBVolume objects by selecting on the MountPath (or other property) of the volume. Combine WBVolume objects as a list and add to the WBPolicy with Add-WBVolume.
$volC = Get-WBVolume –AllVolumes | Where {$_.MountPath –eq “C:” }
$volD = Get-WBVolume –All | Where {$_.MountPath –eq “D:” }
Add-WBVolume –policy $BPol –volume $volC,$volD
4.) Exclude Files/Folders from Backup
Next, create a new WBFileSpec object for each exclusion or inclusion. Inclusions and exclusions are assumed to be recursive unless -nonrecursive is specified. If no inclusions or exclusions are specified for a volume that is included, then the entire volume is assumed. Add all the WBFileSpec objects as a list to the WBPolicy.
$exclTemp = New-WBFileSpec –FileSpec D:\Temp –exclude
$exclMP3 = New-WBFileSpec –File “D:\Users\*.MP3” –exc
$exclWMA = New-WBFileSpec -File “D:\Users\Charlie\Music\*.wma” –exc –nonrecursive
$FileExclusions = $exclTemp,$exclMP3,$exclWMA
Add-WBFileSpec -policy $BPol -filespec $FileExclusions
5.) Define Backup Target/Device
Define one or more backup targets. WBBackupTarget objects can be dedicated external disks, dedicated or shared internal disks, or network share.
You can define a Backup Target as an external disk by selecting it from the WBDisk objects on the system.
$extDisk = Get-WBDisk | where {$_.Properties –eq “External, ValidTarget” }
Add-WBBackupTarget $BPol –target $extDisk
To back up to a network share, you need to first set the credential that will be used to connect to the share using Get-Credential.
$cred = Get-Credential DOMAIN\User
$netTarget = New-WBBackupTarget -NetworkPath \\server\share -cred $cred
Add-WBBackupTarget -policy $BPol -target $netTarget