After the release of VMware vSphere 6, the vCenter Server Appliance 6 (Linux) has a possibility to run vPostgres internal DB. The VCSA with vPostgress DB can support up to up to 1000 hosts and 10,000 VMs using the embedded database. If you running vCenter server 6 appliance (VCSA) the built in vPostgres database can be backed up separately. VMware provides a Python based scripts which allows to backup and restore the built-in DB.
I have tested their solution in my lab. You can use this tutorial to test it as well. You don't have to have much Linux skills. Me too I'm rather Windows guy, but few Linux commands is a must those days… 🙂 I used two tools for the job – Putty and WinSCP. I guess the wast majority of IT admins know those tools and how to use them. Both are listed on my Free Tools page as well. In fact I just followed a VMware KB as a reference. You'll find the link inside the tutorial (you'll need to download the Python scripts) and also below the post. This post is for everyone who want to test backup and restore vPostgres database on VCSA 6.
In case you're still running on VCSA 5.5, you might want to check how my lab upgrade was – How to Upgrade from VCSA 5.5 to 6.0 – Lab Time.
How to backup and restore vPostgres database on VCSA 6 – The steps:
Step 0: Download this script from VMware KB (you'll find it attached at the bottom) > unzip the content (you'll get 2 files backup_lin.py and restore_lin.py)
Step 1. login as a root via SSH client and copy the two files to a /tmp folder on the appliance.
Step 2. Make the backup_lin.py executable with this command
chmod 700 /tmp/backup_lin.py
like this:
Step 3: run the backup_lin.py command to backup the db
python /tmp/backup_lin.py -f /tmp/backup_VCDB_vladan.bak
Result…
Then check the directory with ls -l to see the details on size etc…
If you want you can copy that file outside of the VCSA to have it on different location as well… Below screenshot showing WinSCP used for this…
How to restore?
Step 1: The restore operation is similar, but before we do a restore we need to stop some VMware services…
service vmware-vpxd stop
service vmware-vdcs stop
Step 2: run this command to restore:
restore_lin.py -f /tmp/backup_VCDB_vladan.bak
or whichever name you gave it…
You should see
Restore completed successfully message
The Original VMware KB is here. Check it out!
While the wast majority of the backup products out there is not for the moment compatible with vSphere 6 you might use this method to backup your DB “just-in-case”…. But those products shall be compatible quite soon. Veeam announced the compatibility of vSphere 6 in a reasonable time as they're working towards complete compatibility with vSphere 6 including VVOLs.
One product should't have problem with backing up VCSA however – vSphere Data Protection 6 which has been released at the same time that vSphere 6. I haven't tested VDP 6 just yet, but it's on my To-do list… Subscribe to my RSS or follow via Twitter or FB. In case you did not know, the blog has daily updates. That's why it's been listed as N 13 most popular Virtualization Blog … -:) Stay tuned for more !!
John says
postgresql – vCSA 5.5 vPostgres backup routine – Stack …
John Nicholson says
Hi Vladin,
Thanks for the tips on this backup utility. I was looking for a way to back up the Postgres DB in the new Vcenter 6 appliance and I ran across your blog. One thing I found out was that the /tmp directory in the appliance is truly temporary. I set up a cron job last Friday to dump my backups from the python script to /tmp/bu and came in Monday to find the bu directory was gone! No big deal, I am going to tweak my cron job and move the location of the python dumps to a directory I created called /bak and hopefully this directory wont be auto purged.Thanks again for the tips on the backup of the appliance.
John
Brian says
Great article. Is there a script for vCSA 5.5?
Vladan SEGET says
Yes, check this. http://www.vladan.fr/backup-restore-vcsa-5-5-internal-database/
David says
Now if we could only get it to save the DB to a NFS it would be great!
Andrei says
Hi,
Any way to use Veeam to backup the whole VCSA without using this method? Of course, with the DB in a consistent state?
Thanks,
Andrei
Vladan SEGET says
Ofcourse! Veeam can back Full VM without problem. This post is not a solution for a “normal” people….
Ahmed123 says
Hi Vladan,
Can I backup the PostgreSQL from vCenter 6.0 and restore in MS SQL 2014?
Basically, want to migrate the Database from PostgreSQL to SQL 2014 , while maintaining the same vCenter server v6.0 u2
Regards
Ahmed
Vladan SEGET says
Hi Ahmed,
If I were you, I’d check with your VMware support if this is supported scenario. But it’s a good question.