Backing up a Linux-based vCenter Server Appliance

To back up a Linux-based vCenter Server Appliance, you must modify the VMware pre-freeze and post-thaw scripts on the vCenter virtual machine to avoid corrupted vCenter backups.

Procedure

To modify the scripts, complete the following steps:

  1. On the virtual machine, navigate to the /usr/sbin directory and replace the content of the pre-freeze-script script with the following content:
    #!/bin/bash
    #set log directory
    log="/var/log/vpostgres_backup.log"
    #set and log start date
    today=`date +%Y\/%m\/%d\ %H:%M:%S`
    echo "${today}: Start of creation consistent state" >> ${log}
    #execute freeze command
    cmd="echo \"SELECT pg_start_backup('${today}', true);\" | sudo /opt/vmware/vpostgres/9.4/bin/psql -U postgres >> ${log} 2>&1"
    eval ${cmd}
    #set and log end date
    today=`date +%Y\/%m\/%d\ %H:%M:%S`
    echo "${today}: Finished freeze script" >> ${log}
    
  2. Replace the content of the post-thaw-script script with the following content:
    #!/bin/bash
    #set log directory
    log="/var/log/vpostgres_backup.log"
    #set and log start date
    today=`date +%Y\/%m\/%d\ %H:%M:%S`
    echo "${today}: Release of backup" >> ${log}
    #execute release command
    cmd="echo \"SELECT pg_stop_backup();\" | sudo /opt/vmware/vpostgres/9.4/bin/psql -U postgres >> ${log} 2>&1"
    eval ${cmd}
    #set and log end date
    today=`date +%Y\/%m\/%d\ %H:%M:%S`
    echo "${today}: Finished thaw script" >> ${log}