You can use the vSphere
Automation API to create a backup job for a vCenter
Server instance.
The following sample script illustrates how you can
back up a vCenter
Server instance by
using the vSphere
Automation API.
Prerequisites
- Verify that you are connected to a
vSphere
Automation API server.
Procedure
-
Get the service that deals with
backup jobs.
$backupService = Get-CisService com.vmware.appliance.recovery.backup.job
-
Create a backup specification.
$backupSpec = $backupService.Help.create.piece.Create()
-
Populate the backup specification.
$backupSpec.parts = @("common","seat")
$backupSpec.backup_password = $BackupPassword
$backupSpec.location_type = "FTP"
$backupSpec.location = $ftpLocation
$backupSpec.location_user = $userName
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$backupSpec.location_password = $password
$backupSpec.comment = "My vCenter Server instance full backup"
-
Initiate the backup.
$backupJob = $backupService.create($backupSpec)
-
Check the backup progress.
$progress = ($backupService.get("$($backupJob.ID)").progress)