physical2virtual.backup

a simple idea of including virtualization into your virtual disaster recovery plan

Chapters

1. Planned network infrastructure
2. Making copy of physical server into virtual using VMware converter GUI
3. Making copy of physical server into virtual with command line p2vtool and preparing XML file needed for vmware p2vtool
4. Bat script for automation of vmware converter import process
5. Customizing VMware configuration file
6. Running and testing virtual server using cold and hot methods
7. Restoring network configuration to virtual network adapters
8. Automating vmware server take over process
9. Restoring virtual newly created data to new physical servers

1. Planned.network.infrastructure

backup network of p2v virtual backup
Here I will describe how I imagined and resolved network infrastructure for p2v backup. My backup network now consist of three servers but in future I will extend this network to all other servers. We will call servers primary secondary and backup server what is the most important server in this process.
Primary and secondary server are Microsoft Windows 2003 32 bit terminal servers each hosting around 50 users. Servers are using two AMD processors, each with 4GB of RAM and RAID mirroring with 3Ware raid controllers. I think this is pretty customized server and vmware importer is ready to deal with this kind of network hardware.

As you can see on the backup scheme picture each of server have two 1GBit nics and servers are connected to 1GBit HP procurve network switch to make live images as fast as possible, we will call this subnet a backup network. backup network is build from fast a reliable network components and it is used only to make vmware backup images, here called p2vbackup images. I have used 1Gbit network cause my servers have lots of data, together they consist of 100GB of data that need to be transferred every night to the backup server. Unfortunately there is no possibility now to make incremental images but we will solve this in future somehow.
Also servers are connected to other 100Mbit switch that is connected to normal network infrastructure that is used for users to access, and users from Internet to access Microsoft Windows terminal servers.

2. Making copy of .physical server. into .virtual. using VMware converter GUI

backup network of p2v backup
For importing machines into virtualized environment we will use vmware converter great application from vmware. First I will describe importing with vmware converter using GUI interface, then GUI will generate required xml file that we will use with command line version of vmware converter called p2vtool.

Lets get started.
In the first screen you will choose your source physical machine that will be copied to the virtualized environment. As you can see on my screen shoot my backup network is on the subnet 192.168.100.x, where 1 is backup server and other two server are 2 and 3. In the source server type IP or name of your source machine and in the authentication write credentials in the form of IP\username or NETBIOSname\username and below that enter password.

vmware converter backup source type

If username and password are correct on the destination machine you will be taken to the source data screen. Here are all physical disks on the source machine. On my screen there is only one disk with the size of 250GB. Please note that vmware converter will create virtual disk image file with the size of only used space, so in this case on the destination driver there is approx 35GB of data needed. We will ignore copy of page file and hibernation files from source machines as that data will be created by windows by it self when machine is booted.
vmware converter source data

After preparation from where and what will be imported we will come to the destination type of new imported machines. Here we will specify where will machines be imported. We will prepare this machines for free version of vmware server so we will choose second option vmware standalone virtual machine.

vmware converter destination type

Now we will get to the screen where we will enter name for the virtual machine that is going to be created and where that machine should be stored. For store location we will select virtual backup server share and make sure that share is available for access to the destination server and to the source server. In connect as enter required date in the form of IP\username or NETBIOSname\username and below that enter password. Type of the virtual machine will be vmware server machine.

windows virtual vmware converter destination type

After virtual machine name and location has been set we will come to screen where we will decide how vmware backup image is stored on the backup machine disk. As this little howto is assumed to create backup to the virtual machines we will choose fastest possible option and that is allow virtual disk files to grow. By selecting this vmware converter will allocate disk as needed for virtual machine, and we will not loose time for preallocation of virtual disk. This is chosen cause we predict that this virtual machine will not be used often, and creation of this machine should be fastest as possible.

vmware converter disk space allocation

Now on the order is NIC configuration of virtual machines. It is important that we select for NICs not to connect at power on of virtual machine. This is cause destination machine is same as the source machine and by powering two same machines in the same time we will surely messed up network settings. This backup machine is assumed to be backup of virtual machine so for test we should select not to power virtual NICs. With VMware server script we can later set up some kind of heartbeat system with this, we will set pinging of real live machines from this virtual backup machine and if main machines are not available then we will connect virtual NICs of the virtual machine and then virtual machine will take duty of the main servers.
Also important note is as vmware will create new network interfaces with vmware tools in the virtual machine network settings of the main machine wouldn't replicate to the virtual machine cause there will be different network interfaces involved. We will fix this with automatic restoration of network interfaces with netsh windows command line feature netsh.

vmware converter disk virtual NIC

You will be taken now the customization screen where you can customize settings of the virtual machine such as NETBIOS name, IP, serial number for windows re installation, automatic join to domain and so on. As this virtual machine is assumed to be backup of the main server we will not customize any of this settings, we will leave it as is meaning we will get complete mirror of primary server machine. There maybe would be problem with windows new HAL detection and then you can use vmware customization cause vmware will use sysprep to reset windows HAL and install new. Note with this customization you can also set needed IP network configuration. Without this IP addresses to the virtual machine are assigned by DHCP. I haven't used this cause I wanted to minimize time required for booting windows machine, and this customization will trigger windows reinstall that will last at least one hour. IP addresses we will assign later with netsh command line program.
vmware converter machine customization

Now we are done, next screen is summary screen and just press finish to complete first import via GUI interface. This is also important cause now you know what command line tool in detail is doing and you will easier understand xml file that is needed as configuration for command line tool.

vmware converter is ready to start

Importing process will start and it will last depending on how much data you have and how fast is your network. My speed is via 1Gbit network around 40GByte per hour more or less. Medium speed is at 15MByte per sec, but it can oscillate a much so average is at 11.11Mbyte per sec what is 40Gbyte per hour. Not quite speed for 1GBit NICs but I must optimize this in future to at least 25Mbyte/sec.

3. Making copy of .physical server. into .virtual.with command line p2vtool

Main thing why we want to convert physical server to virtual via command line tool is to schedule work so we don't need to click every night to make a backup.
Now we don't want to loose time when GUI Vmware converter is working so will take a look at XML file that GUI program has created. At the backup machine go to the "c:\Documents and Settings\yourusername\Application Data\VMware\p2v30\jobs\" and there you will see one XML file if you have made only this one conversion or multiple if you had conversion before. ID in the GUI is same number here, so in the GUI where conversion ID is 1 here is at file 00000001.xml. Open that file and take a look at it. At first look it seems pretty complicated but it is not, it is already generated file that GUI version used for conversion. In this file there only miss passwords for accessing share where source machine will be copied (destination credentials) and source machine credential for installing vmware ufad service for making conversion. I have copied file to "c:\Program Files\VMware\VMware Converter\" and we will manipulate with file from there cause that is the location of p2vtool. You can also rename file to something that is easier to remember(here we will call it primary.xml and secondary.xml)
We must add at three locations in the xml file user credentials.
Now open again file if you have closed it and find creds host tag. It will look something like
<creds host="" password="" port="0" username=""/>
Now we must enter here what is source and what are the credentials for the source. Change to your source IP or NETBIOS name, enter your pass and your username.
<creds host="192.168.100.3" password="mypassword" port="0" username="192.168.100.3\username"/>
Now locate in the file
<dest>
<hostedSpec path="\\192.168.100.1\shared" username="192.168.100.1\yourusername" password="yourpassword" vmName="primary"/>
</dest>
This is destination computer and location on the destination computer where backup will be copied. Fill up data with your settings.
Now the last where we must enter credentials:
<importedVM>
<hostedSpec password="yourpassword" path="\\192.168.100.1\shared\primary\primary.vmx"/>
</importedVM>
Now this is it, we have prepared XML configuration file for making backup of the machine from command line.
First wait for vmware converter GUI interface to finish and then we will make a little test of this command prompt tool. To test newly created XML file go the VMware converter installation folder and type in command prompt:
p2vTool.exe -p -i -s primary.xml
By typing only p2vTool.exe you will get whole list of possible switches. Here we have used:
-p switch for VMware post-processing, I have noted if this switch is not used newly created vmware machine wont boot
-i p2v import
-s Input xml file, default is p2v.xml

Now you can note that tool will first connect to the destination server, if not first vmware-ufad service will be installed and then connection will be created.
If everything is done OK, you will now have created and ready machine prepared for backup test. If something is wrong please make sure that you followed this doc from word to word, and if still something is not working feel free to contact me over email.

4. bat script for automation of.vmware converter. import process

I have created script that will automate whole job of importing process via vmware p2vtool. I will paste whole script here and describe in comments what some of the lines are doing.
ECHO dismounting main servers drives
REM I am using vmware backup images as disks to backup from to other remote locations so I am
REM here mounting images to have access to image files. Images are mounted via vmware tool
REM called vmware mount as x and y drives. In this particular lines images are dismounted
REM so I can make new backup and images are mounted at the end of the script. Switches
REM /f /d for forcing dismount of the vmware images although some body is accessing files

cd \
cd Program files
cd vmware
cd VMware DiskMount Utility
vmware-mount x: /f /d
vmware-mount y: /f /d
ECHO removing old images
REM Old vmware images are removed cause vmware converter don't have option to overwrite older files
cd \
cd shared
rd /S /Q primary
rd /S /Q secondary
cd \
cd Program files
cd vmware
cd vmware converter
ECHO Start Time >> stopwatch.txt
REM I am starting a stopwatch to have stats how long will take vmware images to create, and how much of
REM time is spend to make this images
date /T >> stopwatch.txt
time /T >> stopwatch.txt
REM Here is first image started
p2vTool.exe -p -i -s secondary.xml
ECHO Mounting secondary server drive
cd \
cd Program files
cd vmware
cd VMware DiskMount Utility
REM after image is maked I will mount this image for other needs
vmware-mount y: "c:\shared\secondary\secondary.vmdk" /v:1
cd \
cd Program files
cd vmware
cd vmware converter
REM Here is second image started
p2vTool.exe -p -i -s primary.xml
REM I am now copying before customized vmware vmx files that are needed for machine to function properly
ECHO copy vmware customized config
cd \
cd shared
copy /Y primary.vmx C:\shared\primary
copy /Y secondary.vmx C:\shared\secondary
REM Moving files to other location to protect them from deleting by this script
REM This script will delete vmware images cause vmware converter will need to make new files
REM But if physical server is not available script will delete images and we will not have backup
REM with this I have secured backup images from deletion by own create script
ECHO moving files to protect from overwrite p2vtool cannot by itself overwrite
cd \
cd shared
cd primary
move /Y primary.vmdk c:\shared\actual\primary
move /Y primary.vmx c:\shared\actual\primary
cd \
cd shared
cd secondary
move /Y secondary.vmdk c:\shared\actual\secondary
move /Y secondary.vmx c:\shared\actual\secondary
ECHO Mounting primary server drives
cd \
cd Program files
cd vmware
cd VMware DiskMount Utility
REM after image is maked I will mount this image for other needs
vmware-mount x: "c:\shared\primary\primary.vmdk" /v:1
cd \
cd Program files
cd vmware
cd vmware converter
REM stoping stopwatch for statistical needs
ECHO End Time >> stopwatch.txt
time /T >> stopwatch.txt
ECHO ------------------- >> stopwatch.txt

Now you will need only to schedule this script run by schedule task and thats it. Automatic creation of p2v backup images will start every night, or every time you schedule it.

5. Customizing vmware configuration .files.

All changes that I describe here are applied at virtual machine configuration file called .vmx file. Now I have machines with AMD X2 dual core processor and that processors are not working OK with vmware on its default configuration so we must make little configuration change at vmware to fit virtual machines. This problems seems to not appear on any Intel processors but AMD claims that this will be fixed ASAP. I have tried various fixes for vmware but just one helped me MemTrimRate variable. It was set to -1 but when I have change it to MemTrimRate = "0" then everything was working fine. I will also describe other switches that somebody can use. My problems was that machine was running to slow, it needed to but about 15-20mins, and work was impossible with anything.
On some computers problem is with time sync between vmware virtual server and physical computer to resolve this you can try first installing AMD Dual-Core Optimizer from
http://www.amd.com/us-en/Processors/TechnicalResources/0,,30_182_871_9706,00.html
If this isn't helping then try turning off physical and virtual processors.
I have two amd dual cores processor what makes 4 processors for vmware virtual server. For turning off last three processors we will use command:
processor0.use = TRUE
processor1.use = FALSE
processor2.use = FALSE
processor3.use = FALSE
If you have time sync problems, for example time in the vmware virtual backup machine is running a lot faster or a lot slower then on real machine then we will use follow commands:
# entry below is for 2.33 GHz processor
host.cpukHz = "2330000"
host.noTSC = "TRUE"
ptsc.noTSC = "TRUE"

When windows installation is copied to another system it requests reactivation of the windows. On some HP systems this you can avoid this by typing in vmx file smBIOS.reflecthost="TRUE"
.

6. Running and testing .virtual server.using cold and hot methods

We now have ready virtual image and vmx files that are configure that virtual image for running. Run vmware server logon, and press run button and see how your vmware virtual backup machine behaves.
Here I had one single problem that it is so stupid that in one time I was thinking to leave this whole idea and vmware process for some other time.
My physical servers are connected to the UPS and they are configure that if there is no power to turn off server in few minutes, so data is not corrupted or something like that. When I copied that physical server to virtual using vmware converter UPS was configured like on real server. When machines are turned on, windows was booted machine would initiate shout down problem. I tried everything with vmware backup server and nothing would help cause problem was in windows installation. I have noted that windows wont shut down if they are in the safe mode. My only idea was to try turning off and on services cause some of the services initiate windows shut down. I was started and figured that maybe UPS service is fooling around. I was right, when service is disabled windows would stay on in full mode.
For full server function it is only needed to install vmware tools that network adapters, vmware scsi HDD driver and graphics from vmware are correctly installed. Run a live test with your server and if everything is OK you're ready to do some final test to automate this whole process.

7. Restoring network.configuration.to virtual network adapters

When we copied server server from physical to vmware virtual server network settings for physical NIC's are the same as on the physical server what is logical. If we want to copy network settings from physical NIC's to vmware virtual NIC-s we will use little script\trick for dumping and importing network settings.
For dumping current network configuration on your physical server use:
netsh interface dump > netcfg.dat Now open that file and you will see all your network settings configured in there. Take a look specially at "Interface IP Configuration for "Local Area Connection" and if you have backup network like me at "Interface IP Configuration for "Local Area Connection 2".
Now for the vmware backup server we will need to "paste" this IP configuration at different network adapters as on physical server. When vmware vmtools are installed server will get two extra local area network connections called Local Area Connection 3 and Local Area Connection 4. This 3 and 4 connections are vmware virtual adapters that we will configure as primary adapters.
Now in the netcfg.dat file you will nee to change every Local Area Connection to Local Area Connection 3 and Local Area Connection 2 to Local Area Connection 4. With this way we will force settings of the physical NIC's to apply to the virtual NIC's.
My file looks like this:
# Interface IP Configuration for "Local Area Connection 3"
set address name="Local Area Connection 3" source=static addr=192.168.0.2 mask=255.255.0.0
set address name="Local Area Connection 3" gateway=192.168.0.254 gwmetric=0
set dns name="Local Area Connection 3" source=static addr=195.29.150.3 register=PRIMARY
add dns name="Local Area Connection 3" addr=195.29.150.5 index=2
set wins name="Local Area Connection 3" source=static addr=none
# Interface IP Configuration for "Local Area Connection 4"
set address name="Local Area Connection 4" source=static addr=192.168.100.2 mask=255.255.255.0
set dns name="Local Area Connection 4" source=static addr=none register=PRIMARY
set wins name="Local Area Connection 4" source=static addr=none

Now this customizes file save somewhere on your physical machine that you can restore it on the virtual when it is neede. When virtual machine is booted you can restore this customized virtual file with the command: netsh exec netcfg.dat
When this command is executed virtual network adapters will be preconfigured as physical and server is now prepared to accept network connections as physical server would cause now vmware server will be on the same subnet network as physical was.
To test virtual server turn off physical servers and just connect virtual servers to network.

8. automating.vmware server.take over process

For now as you can see everything is done manual by human intervention.
For future we are planning to implement VMware server perl script for automatic take over of production servers. Take over scripts will be based od simply pinging production servers or checking network services and if some of the services is not available script will automatically start required server, install vmware tools, disable UPS service (this is not needed for some of the systems), change network configuration and at last connect virtual server to physical network.

9. Restoring virtual newly created.data to new.physical servers

Lets assume that virtual servers for few days correctly exchanged production servers. In virtual servers you have data that people updated in the meantime and now you want to pull that data from virtual servers and place them on newly restored OLD physical server.
There is no automation for this job, everything is done manually. Let's say that you have databases like SQL and Access that users fill with data. In my virtual disaster recovery plan there is a lot job to be done for system administrator to restore data from virtual to physical server.
System admin (me) should restore manually over the weekend all SQL & Access DB. For SQL I haven't automated process yet and I am runnig simple export/import and for Access I have little script that will pack data into single zip file on other location, so I need just to copy newest Access DB from zip file on new physical production server. After this job is done I have all fresh data on newly restored server.

Main sense of whole project is to keep employees work without interruption caused by server hardware. This process provides low cost failover solution without datacenters or clusters or expensive special hardware and software.
Please note that this project is not best for all server backups, the best would be to contact me with extensive network, servers and data types information and I will suggest is this good solution for you.