Back up a vCenter Server Instance

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

  1. Get the service that deals with backup jobs.
    $backupService = Get-CisService com.vmware.appliance.recovery.backup.job
  2. Create a backup specification.
    $backupSpec = $backupService.Help.create.piece.Create()
  3. 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"
  4. Initiate the backup.
    $backupJob = $backupService.create($backupSpec)
  5. Check the backup progress.
    $progress = ($backupService.get("$($backupJob.ID)").progress)