Oct 172017
 

The folks on the VMware API team along with some Community Support ( <a href=”https://twitter.com/butch7903″ target=”_blank”>@butch7903</a> – Russell Hamker)
have created an amazing backup script for your vCenter Appliance.  Give it a once over.
<a href=”https://github.com/butch7903/PowerCLI/blob/master/Backup_VCSA_DB_to_File.ps1″ title=”Backup VCSA To Flat File – Github” target=”_blank”>https://github.com/butch7903/PowerCLI/blob/master/Backup_VCSA_DB_to_File.ps1</a>

Some quick notes:
- Only works on vSphere 6.5 and higher.
- It requires PowerCLI version 6.5.3 or greater.
- It needs the Powershell PSFTP or WinSCP Powershell module if you want to use FTP or WinSCP to copy the backup from vCenter to a storage location.
* (Optional) – I deployed a Photon OS VM and I use that as my SCP target to save my backups.

If you want to save all of the Command Line GUI in the 772 Line file, all you need are these lines to complete the backup.
Import-Module -Name VMware.VimAutomation.core
Import-Module -Name WinSCP
connect-cisserver “vcenter01″ -username “administrator@vsphere.local” -pass “myPass”
$BackupAPI = Get-CisService com.vmware.appliance.recovery.backup.job
$CreateSpec = $BackupAPI.Help.create.piece.Create()
$CreateSpec.parts = @(“common”,”seat”)
$CreateSpec.backup_password = “”
$CreateSpec.location_type = “SCP”
$CreateSpec.location = “10.10.10.10/storage”
$CreateSpec.location_user = “root” #username of your SCP location
$CreateSpec.location_password = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList “backup location username”, (ConvertTo-SecureString –String “backup location password” –AsPlainText -Force)
$CreateSpec.comment = $Comment
$BackupJob = $BackupAPI.create($CreateSpec)

Then you can use the following command to check on its status:
$BackupJob | select id, progress, state