VMware Cloud Community
BWinchell
Enthusiast
Enthusiast
Jump to solution

How to backup Postgres on VCSA 6.x - Automatically

Hello,

For those of you out there that use the VCSA, how are you getting a DB consistent backup automatically?

In the 5.x days, I had a script that ran locally on the VCSA that dumped the DB and compressed it.  Then an outside file server connected, copied the files to itself, essentially keeping a few days of backups on the VCSA and long-term on the file server.

(https://communities.vmware.com/thread/449667)

Now with VCSA 6.x, things work a little different.  I have created the updated backup script that runs locally (attached below) and that runs fine.

The issue I have is "how do I get the files off the VCSA via automated process?".

With the change of the shell environment on the VCSA, trying to accomplish this via code (bash in my case) is not working.  I do not want to change the default shell permanently to resolve this (trying to change as little as possible on VCSA to avoid any

complications for future releases).

Maybe someone can shed some light on how this can be accomplished.

Thanks

B

Reply
0 Kudos
1 Solution

Accepted Solutions
BWinchell
Enthusiast
Enthusiast
Jump to solution

***THESE ARE NOT OFFICIALLY SUPPORTED SCRIPTS FROM VMWARE....BEWARE***

Ok....after trying many different ways to get the procedure to work the way I want, the roadblocks that VMware put up were too big.  I wanted the automated process to change as little as possible on the VCSA (obvious reasons).

So the solution was to have the copy functionality be executed by the VCSA (not the way I want it but to get around the road blocks).  So basically on the VCSA, the script creates the backup, zips it, verify the size (could not find any Postgres command that actually runs a verification process), and then copies the files to a repository.

Prerequisites:

  • Setup SSH authentication keys (http://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix/)
    • You might have to enable the local root account on the destination server to copy the  SSH id over (and then disable root account)
      • Debian
        • “sudo passwd root” = enable account
        • “sudo passwd –l root” = disable account
  • Copy the script into /etc/cron.daily (bash_backup_vcdb on the VCSA & bash_transfer_backups on repository)
  • Rename to bash_backup_vcdb (remove the “.sh” at the end of the file)
  • Make executable (chmod +x %filename%)

Hopefully, VMware can put some sort of automated process in the next release of the VCSA.  It has been around for long enough.

Thanks

B

View solution in original post

Reply
0 Kudos
5 Replies
greco827
Expert
Expert
Jump to solution

Do you have VDP or some other backup application that runs which can back up the VCSA at the .vmdk level?

If you find this or any other answer useful please mark the answer as correct or helpful https://communities.vmware.com/people/greco827/blog
Reply
0 Kudos
BWinchell
Enthusiast
Enthusiast
Jump to solution

We currently use Veeam 8.x for all of our virtual backups.

Thanks

B

Reply
0 Kudos
greco827
Expert
Expert
Jump to solution

Use a two tiered approach.  Use the local backup to backup the database onto the appliance itself, and then have Veeam come in and do a backup of the entire VM (or incremental).  If you have to restore based on a corrupt database, you should be able to use the local.  If the whole VM is down, you can restore the entire VM (or just the database if Veeam is capable of cracking open the .vmdk and doing file level restores like Netbackup).

If you find this or any other answer useful please mark the answer as correct or helpful https://communities.vmware.com/people/greco827/blog
BWinchell
Enthusiast
Enthusiast
Jump to solution

That is one approach that will work.

In the past we have avoided stunning our VC as it is disruptive to any active tasks (have seen some weird results but have not tested this on the 6.x platform).

I will do some tests to see how this works out.

Thanks

Reply
0 Kudos
BWinchell
Enthusiast
Enthusiast
Jump to solution

***THESE ARE NOT OFFICIALLY SUPPORTED SCRIPTS FROM VMWARE....BEWARE***

Ok....after trying many different ways to get the procedure to work the way I want, the roadblocks that VMware put up were too big.  I wanted the automated process to change as little as possible on the VCSA (obvious reasons).

So the solution was to have the copy functionality be executed by the VCSA (not the way I want it but to get around the road blocks).  So basically on the VCSA, the script creates the backup, zips it, verify the size (could not find any Postgres command that actually runs a verification process), and then copies the files to a repository.

Prerequisites:

  • Setup SSH authentication keys (http://www.cyberciti.biz/faq/how-to-set-up-ssh-keys-on-linux-unix/)
    • You might have to enable the local root account on the destination server to copy the  SSH id over (and then disable root account)
      • Debian
        • “sudo passwd root” = enable account
        • “sudo passwd –l root” = disable account
  • Copy the script into /etc/cron.daily (bash_backup_vcdb on the VCSA & bash_transfer_backups on repository)
  • Rename to bash_backup_vcdb (remove the “.sh” at the end of the file)
  • Make executable (chmod +x %filename%)

Hopefully, VMware can put some sort of automated process in the next release of the VCSA.  It has been around for long enough.

Thanks

B

Reply
0 Kudos