Automated backups of vCenter Server Appliance (VCSA)

Having recently had a vCenter Appliance database corrupt following an all paths down scenario, I went looking for a way to backup the database. I found KB2034505, which details the steps of doing exactly that! The only issue with this approach is that it is a one-off process. However, since the VCSA is just a Linux appliance, we can leverage this to implement a cron task to backup regularly.

To do this, I first created an NFS share on my Update Manager server (hey, one good thing about having to have a Windows server for you VMware management, right?). I won’t go into detail here, but if you are interested let me know in the comments and I can expand on this. You will also need to create the mount point (I used /mnt/DBBackup)

To perform the actual backup, I created a file in /etc/cron.daily/ named To do this simply SSH to your appliance, and run vi /etc/cron.daily/

Press i to enter insert mode, and paste the following code (update the nfsshare variable to match your NFS server details):

now=$(date +"%Y%m%d")

mount.nfs $nfsshare /mnt/DBBackup
/opt/vmware/vpostgres/1.0/bin/pg_dump VCDB -U vc -Fp -c | gzip > /mnt/DBBackup/$hostname/DBBackup-$hostname-$now.bak.gz
chmod 777 /mnt/DBBackup/$hostname/DBBackup-$hostname-$now.bak.gz
umount.nfs /mnt/DBBackup

Press Esc and then :wq to save the file. Next, change the script to be executable by running chmod +x /etc/cron.daily/

As you can see, this takes a dump of the database, runs it through gzip to compress the file (I’m getting ~500MB down to around 60MB since it is just text), and saves to your NFS share in a folder named after your appliance (in case you have more than one like we do).

The caveat to this is that the vCenter services are not stopped whilst performing the backup, which is part of the KB article – for us we wanted to minimise the impact to vCenter services. If you want to add this in it is a simple modification. I also performed a test restore in an isolated environment and the inventory data was populated, however without stopping services there is a small risk that your database backup will be in an inconsistent state.

The next part? Perhaps I will write a small script to cleanup the older versions of the backups on my NFS share…