Scheduled PostgreSQL backup of Cloud Director Embedded DB

Published by Jimmy Mankowitz on

In this post I want to describe how a backup of the PostgreSQL database for Cloud Director can be setup to be scheduled

In the VMware documentation there is only a description on how one could take a manual backup of the Postgres DB. In normal Operations t can be convenient to have this automated and scheduled.
I want to create a daily backup of the database and save that on the NFS Transfer Store inorder to be able to create Image backup of the NFS Server.

To start with I use an old tool called Cron that’s included in the Cloud Director Cell.
Cron is running it’s schedules from the directory that is placed at /etc/cron.d/
So in order to create a backup for Postgres we simply create a new file in the location. Called: vcdpostgres_db_backup

In the file we add the following line that creates a backup everyday at 15:00, this can be customized to be once every week or whatever is suitable.

#m  h  dom mon dow user     command
00 15  *   *   *   postgres  /opt/vmware/vpostgres/10/bin/pg_dump vcloud > /opt/vmware/vcloud-director/data/transfer/pgdb-backup/$(date +\%F)_vcloud_postgresdbdump.tgz
00 15  *   *   *   root      find /opt/vmware/vcloud-director/data/transfer/pgdb-backup/_vcloud -mtime +5 -type f -delete

The command runs as the Postgres user and creates a dump of the vcloud database to the location of /opt/vmware/vcloud-director/data/transfer/pgdb-backup.
It finally checks if there are any files that are older than 5 days and deletes them.
Be sure to check that the cron job works by tailing /var/log/cron


Leave a Reply

Avatar placeholder

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