Before we begin, I´d like to point out the obvious: You want to clone a VM that is as clean as possible (without needing to install all the software on each clone of course). So clone your VM before creating any sites, since all references will be broken when you change the name.
This has been tested with a VM containing the following software:
- Windows Server 2008 R2
- SQL Server 2008 Express
- SharePoint 2010 Enterprise
- Visual Studio 2010 Premium
- Office Professional Plus 2010
First, the best way to clone the VM for use in your Hyper-V setting. Contrary to what you might expect, this is not by using the export/import functions of Hyper-V Manager. This is actually meant for backup/restore.
The best way I have found is to just stop the VM you want to clone, copy the VHD, create a new VM definition and attach it to the copied VHD.
Next, the VM must be renamed. These steps are based on the MOSS 2007 cloning steps outlined here: http://www.sharepointdevwiki.com/display/public/Cloning+a+SharePoint+Virtual+Machine
- Stop the SharePoint Search services(s). I stopped both the “SharePoint Foundation Search V4” and “SharePoint Server Search 14” services to be sure.
- Go to System Properties and rename the VM, but don’t restart yet.
- Open “SQL Server Management Studio” and connect to “(local)”.
- Run the following query:
EXEC sp_dropserver '<old_name>' GO EXEC sp_addserver '<new_name>', 'local'
- Run the “renameserver” stsadm command:
stsadm -o renameserver -oldservername <old server name> -newservername <new server name>
- Now restart the VM.
- Rebuild Central Administration:
psconfig -cmd adminvs -provision -port 12345 -windowsauthprovider onlyusentlm
- Restart IIS.
- Open Central Administration and delete the applications that are based on the old machine name.
Aaaand, you’re good to go.
Pingback: Tweets die vermelden Cloning SharePoint 2010 development images (for Hyper-V) | Mark's random .NET stuff -- Topsy.com
In your post above you state the following:
Although this may be true if you want to create a “golden image” to use for SharePoint development, when you want to create an exact replica of an existing SharePoint server for use in a multi-developer environment it only gets you part of the way there.
Is there truly no simple way to perform a rename of the server so that both VM images can co-exist on the same network without breaking any existing SharePoint sites? It seems rather short-sighted of Microsoft to have neglected to recursively update all references in a content database that directly depend on a server name within a SharePoint instance. Did they really generate all of the objects in the content database using strongly-typed names based on the hard-coded server name instead of some kind of variable? Why should customers be expected to take weeks or even months writing complex Powershell scripts in order to successfully bring existing SharePoint sites back online that were created prior to a server rename?
I may have spoken too soon…
I found several sites that offer possible solutions (which I haven’t had a chance to verify yet), but even if any of them do work I’m still a bit disappointed that Microsoft couldn’t have helped automate the entire process with a GUI utility of some sort.