SCVMM DB Backup and cleaning with PowerShell

I have been working on some Virtual Machine Manager deployment and configuring at a customer and after some configuration and misstakes a backup would have been nice. There is a PowerShell cmdlet in the VMM and what it does is to create a DB dump on a path that you specify. Remembering to do this every day that you work with the environment so you can recover is not always so easy and it is often that just after you make a misstake or the system does it for you, the need for backup arrises.

So setting it up with a scheduled job in PowerShell is the way to go, and the script I have also removes the backups after 7 days.

here is the simple script that does the backup and cleaning

# Backup VMM Server
#
# Schedule with either PSScheduledJobs or Task manager
# Niklas Akerlund 2013-06-04
$backupPath = "C:\temp"

ipmo virtualmachinemanager
Backup-SCVMMServer -Path $backupPath

get-item -Path "$backupPath\*" | where {$_.LastWriteTime -lt (get-date).AddDays(-7) -and $_.Name -match "bak"} | Remove-Item

And here is the scheduling that is done with PS Scheduling

backupschedule
$cred = Get-Credential
$dailybackup = New-JobTrigger -Daily -At 10:45PM
Register-ScheduledJob -Name "VMM Backup" -FilePath C:\PowerShell\backupVMM.ps1 -Trigger $dailybackup -Credential $cred

This way you at least have a backup once a day to get you to recover, and talking of recover, if you want to recover the database for the VMM you can use the binary SCVMMRecover.exe and the parameter -Path. You can find the SCVMMRecover in the following path if the VMM is installed with default settings,  “C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin”

Leave a comment

name*

email* (not published)

website