I am afraid I can’t take full credit for this method of backing up my VMWare environment. I suppose I couldn’t anyway, since VMWare invented it. Still though, I had to ask a former colleague how he did it at my previous company, so the credit for this post goes to him. Thanks Mark!
Anyhoo, if you didn’t know, VMWare has made a method for taking snapshots of the virtual machines in your environment and saving them on external storage for backing them up to tape. Many companies like Symantec have added this feature to their backup suites for a little extra. If you don’t have the cash for the extra agent fees you will need, then this solution may be for you.
The tool is called VCB, or Virtual Consolidated Backup. It is free if you are already using vSphere, just install it as a part of the custom install. Once you have it installed, you will need to create three text files. One called Servers.txt, One called VCB.cmd and One called VMBackup.cmd. Place them all together in a folder.
Now, in Servers.txt, write the names of the VM’s you want to backup, using a new line per machine. The names must match the names of your machines in vSphere. For example
You get the idea right? That is the file our script is going to call for backing up to external storage. If you ever need a machine added to the backups, just add it to the list. Got it? Good.
Now that we have our list of servers, we need to edit our VCB.cmd file. In that file put the following commands:
rd /s/q "\\fileserver\share\%1"
Echo Backup of %1 started on %date% at %time%>BackupLog.txt"C:\Program Files\VMware\VMware Consolidated Backup Framework\vcbMounter.exe" -h FQDN.ofyourvsphereserver.com -u username -p password -m nbd -t fullvm -r \\fileserver\share\%1 -a name:%1
Echo Backup of %1 completed on %date% at %time%>>BackupLog.txt
In the above example, change the name of the file server and share to match your environment. Also, change the username and password to match a vSphere user that has full permissions to your VMWare environment.
Now for the final file, VMBackup.cmd. In this file, enter the following command:
for /f %%a in (servers.txt) do call vcb.cmd %%a
This will basically pipe the names of each server into our VCB script, and will save the snapshots to external storage. Once you have all of them setup, create a scheduled task to run VMBackup.cmd on your desired schedule.
Do you use a different method to backup your VMWare environment? What do you do? Let us know in the comments.