Windows Server Backup with PowerShell in Server 2012

Found this one out today. If you use the Set-WBPerformanceConfiguration cmdlet to change from full to incremental, it doesn’t actually¬†do what you think it will.

You basically have 2 options: to always do full backups (i.e. overwrite the current backup with a new full one) or to do incrementals, which essentially appends the changes onto the backup file. There IS NO backup history with this- if you delete something, run a new incremental backup and then expect to go back to the backup from whenever, it doesn’t appear to work. You can only go back as far as the most recent backup and not before, so this isn’t like BackupExec where you can have incremental .bkf files available.

The script below will create a full backup of target Z: at location \\xxxx\yyyy\fullDaily. A couple of things: if you run this script manually from Powershell, it will complain that you haven’t scheduled it. DON’T figure out how to add a schedule, as Windows Server Backup only allows the creation of one schedule. Instead, use Task Scheduler to create as many schedules as you want. Secondly, you can create multiple scripts and point them at different target folders to give you a shot at having multiple recovery points. However this is tricky- as I said above, there doesn’t seem to be a way of creating proper incremental backups (even incrementals run a full the first time around) so you’ll need a LOT of storage. Have yet to figure a way of backing these off to tape, if this is possible at least you could just write the full to tape and then delete it (so you only ever need sufficient space for one full backup, as those backup files will have disappeared by the next backup).

#Creates a folder on xxxx under the yyyy share

#Sets up 3 variables:
#1 create a backup policy variable
$fullDailyPolicy = New-WBPolicy
#2 create a file specification telling the backup job what to backup
$fullDailyFiles = New-WBFileSpec -FileSpec ‘Z:\’
#3 create a target variable telling the backup job where to backup to
$fullDailyTarget = New-WBBackupTarget -NetworkPath \\xxxx\yyyy\fullDaily

#Adds the file specification created above to the policy
Add-WBFileSpec -Policy $fullDailyPolicy -FileSpec $fullDailyFiles
#Adds the backup target created above to the policy
Add-WBBackupTarget -Policy $fullDailyPolicy -Target $fullDailyTarget

#Sets the backup policy to the one populated above
Set-WBPolicy -Policy $fullDailyPolicy
#Starts the backup job
Start-WBBackup -Policy $fullDailyPolicy