本文件已封存並已停止維護。

How to Back Up the VMM Database Using a Script

更新日期: 2009年8月

適用於: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2, Virtual Machine Manager 2008 R2 SP1

You can use the Backup-VMMServer cmdlet for System Center Virtual Machine Manager (VMM) to back up your VMM database. While you can run this script on demand, to automatically back up your VMM database, you need to create a task in the Windows Task Scheduler service.

Explanation of BackupVMMDatabase.ps1

The Backup-VMMServer cmdlet backs up the VMM database from your VMM server. It does not back up the data on the virtual machines.

# Filename:    BackupVMMDatabase.ps1
# Description: Backs up the VMM database.

Connect to the VMM server.

# Specify the VMM server and domain.

$VMMServer = Get-VMMServer -ComputerName "VMMServer1.Contoso.com"

The local path or the network share path you specify must not be a root folder. Additionally, the account under which Microsoft SQL Server is running must have write access to the folder.

# Specify the backup folder path and name. To back
# up a database to a network share, specify the UNC
# path, for example, \\SQLServer01\VMMBackups.

Backup-VMMServer –Path "C:\VMMBackups" -VMMServer $VMMServer

Scheduling a Backup Task

To run the backup script on a scheduled basis, you need to create a task in the Windows Task Scheduler service. The action in your task must start Powershell.exe and load the VMM snap-in in order to run the VMM cmdlets that are used by the script. The following syntax starts Powershell.exe, loads the VMM snap-in, and runs the BackupVMMDatabase.ps1 script located in the C:\MyScripts folder.

Syntax for VMM 2008:

PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft System Center Virtual Machine Manager 2008\bin\cli.psc1" -Command ".'C:\MyScripts\BackupVMMDatabase.ps1'"

Syntax for VMM 2008 R2:

PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft System Center Virtual Machine Manager 2008 R2\bin\cli.psc1" -Command ".'C:\MyScripts\BackupVMMDatabase.ps1'"
顯示: