Backing up and restoring the vCenter Server Appliance 5.x vPostgres database
search cancel

Backing up and restoring the vCenter Server Appliance 5.x vPostgres database

book

Article ID: 342792

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

This article provides steps to back up and restore the vCenter Server Appliance's (VCSA) vPostgres database.

For vCenter Server Appliance 6.0, see Back up and restore vCenter Server Appliance/vCenter Server vPostgres database (2091961).

Note: This article is only supported for backup and restore of the vPostgres database to the same vCenter Server Appliance. Use of image-based backup and restore is the only solution supported for performing a full, secondary appliance restore.


Environment

VMware vCenter Server Appliance 5.5.x
VMware vCenter Server Appliance 5.0.x
VMware vCenter Server Appliance 5.1.x

Resolution

Before you proceed, ensure that you have these installed:
  • SSH client for connecting to the vCenter Server Appliance.
  • WinSCP (or any SCP client) for retrieving and replacing the vPostgres database recovery file.

Backing up the embedded vPostgres database

To back up the embedded vPostgres database:

  1. Connect to the vCenter Server Appliance via SSH. For more information, see Enable or Disable SSH Administrator Login on the VMware vCenter Server Appliance section in the vCenter Server and Host Management Guide.
  2. When prompted, log in as the root user. The default password is vmware.
  3. Stop the VMware vCenter Server service by running this command:

    service vmware-vpxd stop

  4. On the vCenter Server Appliance virtual machine, navigate to the vPostgres utility directory using this command:

    cd /opt/vmware/vpostgres/current/bin

  5. To display the vPostgres database configuration file, run this command:

    cat /etc/vmware-vpx/embedded_db.cfg

  6. To back up the vCenter Server database, run this command:

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

    Fill in the EMD_DB_INSTANCE and EMB_DB_USER from the embedded_db.cfg configuration information listed in Step 5. Fill in the VCDBBackupFile with the location and file name to generated, for example:

    ./pg_dump VCDB -U vc -Fp -c > /tmp/VCDBackUp

    Note: If prompted, enter the EMB_DB_PASSWORD password.

    Caution:
    • The /tmp/ directory is reset after rebooting the vCenter Server Appliance. VMware recommends that if this location is used, backup should be moved to a persistent location.
    • The /tmp/ directory is 6GB in storage space, if the database is larger then this, a different location will be needed.

  7. Using WinSCP, connect to the vCenter Server Appliance and download the VCDBackUp file from /tmp/
  8. Start the VMware vCenter Server service by running this command:

    service vmware-vpxd start

Restoring from the backend vPostgres database file

To restore from the back up vPostgres database file:

Note
: Ensure that you take a snapshot of the vCenter Server Appliance virtual machine before proceeding. This allows you to restore the database from the snapshot if this restore procedure fails.

  1. Connect to the vCenter Server Appliance via SSH. For more information, see Enable or Disable SSH Administrator Login on the VMware vCenter Server Appliance section in the vCenter Server and Host Management Guide.
  2. Using WinSCP, connect to the vCenter Server Appliance and upload the backup copy of the VCDBackUp file into the /tmp/ directory
  3. To display the new vPostgres database configuration file, run this command:

    cat /etc/vmware-vpx/embedded_db.cfg

  4. Navigate to the vPostgres utility directory by running this command:

    cd /opt/vmware/vpostgres/current/bin

  5. Stop the VMware vCenter Server service by running this command:

    service vmware-vpxd stop

  6. To restore the vCenter Server vPostgres database from backup, run this command:

    PGPASSWORD='EMB_DB_PASSWORD' ./psql -d EMB_DB_INSTANCE -U postgres -f VCDBBackupFile

    Fill in the EMD_DB_INSTANCE and EMB_DB_PASSWORD from the embedded_db.cfg configuration information listed in Step 3. Fill in the VCDBBackupFile with the location and file name to be used, for example:

    PGPASSWORD='g<T4EuybGsA=kG$G' ./psql -d VCDB -U postgres -f /tmp/VCDBackUp </font>

    Note: Use single-quotes (') around the password as shown in the embedded_db.cfg configuration file.

  7. To restart the VMware vCenter Server service for the database restore to take effect, run this command:

    service vmware-vpxd start


Additional Information

VMware introduced the VMware vPostgres database as the embedded database packaged with the vCenter Server Appliance in vCenter 5.0 Update 1a and later.
 

For more information on the command line options for pg_dump, see pg_dump from PostgreSQL.