Simple Script to Backup VCenter Appliance Postgres Database

Written by James McDonald

February 12, 2013

Create a backup dir

# create a directory to hold the backup files
mkdir /storage/backup

# create a backup script file

# make it executeable
chmod +x /storage/backup/

Add the following to the backup script


# source the vmware postgres embedded db configuration
. /etc/vmware-vpx/embedded_db.cfg

# get the day of week 1-7 starting mon=1
DOW=`date +"%u"`

# this is what roughly embedded_db.cfg contains
#EMB_DB_PASSWORD='<normally this is a password>'

# specify the postgres password in the PGPASSWORD var
# for pg_dump not to prompt for a password

# as per vmware instructions change to the bin dir

# run pg_dump passing in the correct values
# create a gzipped backup file
./pg_dump $EMB_DB_INSTANCE -U $EMB_DB_USER -Fp -c | gzip > /storage/backup/${DOW}-VCDB.bak.gz

Install a crontab as root

# min, hour, day of mon, month, day of week
3 18 * * * /storage/backup/


1 Comment

  1. Erwin Zoer

    Just wondering:

    # create a backup script file

    should that have read instead:

    # create a backup script file
    touch /storage/backup/


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...

PC Build

I recently built myself a PC using the SilverStone SG13 Case. I am planning to use it as a Hot Spare. So any client...