How to Backup and Restore the VMware vCenter Server Appliance Database (VCSA)

Posted on January 16, 2014 by Brian Suhr in VMware with 0 Comments

The VMware vCenter Server Appliance (VCSA) is the wave of the future, right? Well, that depends on who you talk to. By now you have probably noticed that VMware has been releasing many of their products and tools as virtual appliances. This seems to mean that they may eventually phase out the Windows-based vCenter install. Either way, the VCSA now can support 100 hosts and 3,000 virtual machines, which means that it would be able to support the vast majority of VMware installs.

But to be able to roll out the VCSA in your datacenter you will need to work out a plan for backing up the data. The appliance does not have a built-in backup utility yet. You could use any VMware-based backup tool to backup the appliance as a whole, but that might not be a supported method and you could possibly run into database issues. So for an added level of protection, you will want to take database backups.

In this article I will walk you through the steps to take a manual backup of the internal VCSA database. If you connect the VCSA to an external Oracle database, then you would not need this process. The internal database is a Postgres database and as of vSphere 5.5, it must still be backed up via these commands.

To accomplish this project you will need the following items. These will be needed for remotely connecting into the appliance and copying files.

  • SSH Client – I use Putty
  • SCP Client – I use WinSCP

Sponsored

How to Backup the VCSA Database

In the image below, you can see what the vCenter looks like on the server on which we are backing up the database. The server name is vcsa55 and has a single datacenter and a test cluster.

Backup the VCSA Database

 

  • Connect to the VCSA with the SSH client.
  • Stop the vCenter service with the following command: service vmware-vpxd stop

Backup the VCSA Database

  • Change into the /opt/vmware/vpostgres/1.0/bin folder.
  • You will need to display the Postgres database configuration file. This will show you the database name, username, and password needed.

cat /etc/vmware-vpx/embedded_db.cfg

Backup the VCSA Database

  • Now you will issue the following command to create the database backup. I stored my backup in the /tmp folder.

./pg_dump EMB_DB_INSTANCE -U EMB_DB_USER -Fp -c > VCDBBackupFile

Backup the VCSA Database

  •  Once the backup is completed, the vCenter service needs to be started again.

service vmware-vpxd start

Backup the VCSA Database

 Now that the backup is completed you will need to use the SCP client and connect to the VCSA and copy your backup file. This can be stored some place for safe keeping.

How to Restore the VCSA Database

Now we need to restore our database backup. For this post, I stood up another VCSA that has an empty base configuration. I will then restore the backup and we will see the inventory items from the original VCSA.

  • Use the SCP client to copy the database backup file to the target VCSA virtual machine.
  • Use SSH client into the VCSA.
  • You will need to display the Postgres database configuration file. This will show you the database name, username, and password needed.

cat /etc/vmware-vpx/embedded_db.cfg

restore VCSA Database

  •  Stop the vCenter service with the following command: service vmware-vpxd stop
  • restore VCSA Database

  • Now we need to enter the command to restore the database backup file. The image below shows the results of the command. The screen will be rapidly filled with database commands.

PGPASSWORD=’EMB_DB_PASSWORD’ ./psql -d EMB_DB_INSTANCE -Upostgres -f VCDBBackupFile

restore VCSA Database

  •  Start the vCenter service with the following command: service vmware-vpxd start

restore VCSA Database

  • Once the vCenter service is started back up, open up a web browser and connect to the web client. You will now see the vCenter inventory items that were in the original vCenter. In this example you can see the vCenter name is “restore.” This was my target, but the cluster and datacenter items were restored.

restore VCSA Database

If you are planning on implementing the VCSA in a test or production environment, then you will need to take regular backups of the database. You can use this process, but you would want to script it and run in a Cron job so that it happens on a regular schedule.

Sponsored

Tagged with , , , ,