How to backup Exchange 2013 database on Windows Server 2012

Exchange backup limitations

  • Only Full backup is possible with log truncation (incremental backups do not flush logs)
  • Normal backup performance option does always full backup, but only differences are stored in the disk, while using file block mode.

After initial full backup every other backup of the same volume to the same target is incremental unless the following two conditions are fulfilled:

Configuring Windows backup

Installation

Windows Server Backup feature is not installed by default on Windows 2012 server. To gather status use the following Powershell command:

Get-windowsfeature | where {$_.name -like "*backup*"}

Backup_feature_not_installed

To install Windows Server Backup features run the following commands from Powershell. These commands will install needed features to run Exchange backup via command line tool Wbadmin.

Add-WindowsFeature "Windows-Server-Backup"

after-installation

In backup/restore of Exchange servers we will use Powershell commands. In comparison with previous version of Windows server there is no need to add pssnapin for backup to Exchange Powershell session.

Add new disk for Exchange backups. In script there used “Backup Disk” as volume name. (Depends on the HW you use so no further notice here)

Configuration

To successfully configure Windows Server Backup we must first define backup policy:

$WBPolicyFull = New-WBPolicy									# Create new WB policy object
$WhatToBackup = New-WBFileSpec –FileSpec E:\				# Define what to backup
Add-WBFileSpec –Policy $WBPolicyFull –FileSpec $WhatToBackup 	# Adding what to backup to backup policy
$WBTarget = New-WBbackupTarget –NetworkPath "\\Servername\sharename\path" 	# Selected backup disk will be set as target
Add-WBBackupTarget –Policy $WBPolicyFull -Target $WBTarget 		# Adding target to WB policy
Set-WBVssBackupOptions -Policy $WBPolicyFull -VssFullBackup			# Set method to use WSS Full Backup

Check

To check policy:

$WBPolicyFull

Policy configured in previous step might be started directly

Start-WBBackup -Policy $WBPolicyFull

Or scheduled

Set-WBSchedule –Policy $WBPolicyFull –Schedule 21:00

List backup sets

To list backup sets:

Get-WBBackupSet

Example 1

$WBPolicyFull = New-WBPolicy
$WhatToBackup = New-WBFileSpec –FileSpec E:\
Add-WBFileSpec –Policy $WBPolicyFull –FileSpec $WhatToBackup 
$WBTarget = New-WBbackupTarget –Networkpath "\\Ex13node2\g$\Full"
Add-WBBackupTarget –Policy $WBPolicyFull -Target $WBTarget
Set-WBVssBackupOptions -Policy $WBPolicyFull -VssFullBackup
Start-WBBackup -Policy $WBPolicyFull
Set-WBSchedule –Policy $WBPolicyFull –Schedule 21:00

or create a task

Example 2

Example can be downloaded on My Skydrive (E2013BackupW12.zip)

ZIP file contains:

  • *.PS1 file – script to perform backup
  • *.XML file – windows task file example

This Example creates backup of single mailbox database to local drive and then copies it to network drive.

$dat = get-date
start-transcript "C:\ExchangeScripts\Backups\DB_Backup_$($dat.day)_$($dat.month)_$($dat.year)_report.txt"
write-host "started"
new-item -ItemType Directory -path "G:\Full\$($dat.dayofweek)" -erroraction SilentlyContinue
New-PSDrive –Name “G” –PSProvider FileSystem –Root “\\fileserver\data\ExchangeBackup” –Persist
$target = "\\Ex13node2\d$\ExchangeBackup"
#$target = "\\fileserver\data\Full\$($dat.dayofweek)\ExchangeBackup"
$drive = "G:\Full\$($dat.dayofweek)"
$cleanup = $drive + "\WindowsImageBackup"
Remove-Item -Recurse -Force $cleanup
write-host $target
$policy = New-WBPolicy
$co_zalohovat= New-WBFileSpec -filespec F:\
Add-WBFileSpec -Policy $policy -FileSpec $co_zalohovat
$backuplocation = New-WBBackupTarget -networkpath $target
Add-WBBackupTarget -Policy $policy -Target $backuplocation
Set-WBVssBackupOptions -Policy $policy -VssFullBackup
Start-WBBackup -Policy $policy -force
get-wbjob -previous 1
Get-ChildItem –path $($target) -Recurse | Foreach-Object  { copy-item -Path $_.fullname -Destination $($drive) }
stop-transcript

Result of example

Example_run

This solution works only, when running backup from active database copy on member of DAG, which hosts only active DB copies.