Some of you may have computer labs, or have a network at home may use VMware Server (the free one, not ESX). So I’ve been trying to rack my brains into how to backup these machines at night. Now there are some scripts out there that minimize the downtime to one minute, but they complicated and sometimes don’t work, but if you want to try go to the vmware communities. There is also backup software for VMware ESX like vranger,  and eXpress but these tools are expensive and I’m not sure if they work with VMWare Server. So I created my own script that will suspend the machine for a few minutes copy all the files to another directory and turn the machine back on. It does take a few minutes, but the machines I have are not critical that they must be up every second of the day. If you have machines that are this critical you’ll need to look into one of the above mentioned backup tools.

1. This will suspend the machine (you will need to point to the .vmx file)

VMrun command is located at c:\program files\vmware\vmware vix if you installed the typical installation of vmware server.

vmrun suspend “E:\VMware\Netexceed DC1 (Win23k)\Windows Server 2003 Standard Edition.vmx”

2. While the machine is suspended copy all the files

3. This will turn the machine back on

vmrun start “E:\VMware\Netexceed DC1 (Win23k)\Windows Server 2003 Standard Edition.vmx”

This is a copy of my actual backup batch file. The batch file below does the following. Basically all my vm’s are placed in d:\backups\Virtual Machine Backups. I have a directory for each virtual machine. In this case I have Netexceed dc1 folder. This batch file deletes the directory, and recreates it. It then suspends the machine, copies the files, and turns the machine back one. I then later on come and backup all the files in the virtual machine backups folder with another software (like Syncback) later.

@echo off
echo Starting Server Core backup of Virtual machines
echo ————————————————
echo.
echo.
echo Cleaning current backups…
d:
cd “D:\backups\Virtual Machine Backups”
RD “Netexceed DC1″ /S /Q
RD “Backup Server” /S /Q
RD “Netexceed Exchange x64″ /S /Q
MD “Netexceed DC1″
MD “Backup Server”
MD “Netexceed Exchange x64″
c:
echo.
echo.
echo Suspending domain controller for snapshot backup….
echo.
cd c:\program files\vmware\vmware vix
vmrun suspend “E:\VMware\Netexceed DC1 (Win23k)\Windows Server 2003 Standard Edition.vmx”
echo.
echo Suspended domain controller, copying files for backup…
echo.
xcopy “E:\VMware\Netexceed DC1 (Win23k)” “D:\backups\Virtual Machine Backups\Netexceed DC1″ /y
echo.
echo Backup completed, turning on domain controller….
echo.
vmrun start “E:\VMware\Netexceed DC1 (Win23k)\Windows Server 2003 Standard Edition.vmx”
echo.
echo Backup of Domain Controller completed successfully
echo.