First, I created a list of the sites I needed then a simple batch file containing the MSDeploy commands. Be careful of virtual directories. I had virtual directories that went to some large document repositories. The code I’m giving you only handles the root directory of the site and its physical subdirectories.
appcmd list vdir> c:/sites.text
With some editing of the file, I created an import format that I could use in Excel then used the concatenate excel function to build the msdeploy lines below.
MsDeploy is now a separate install. Once installed you will find it at c:\program files\iis\Microsoft Web Deploy V3. Run your commands from this directory.
It’s a great deal easier to directly transfer all the website files first. I personally use FileZilla between servers. Once done here’s the two commands I use to export a site then import it to a new site. The example site here is 8aSelect and I kept the archivedirectory in c:\resources
Command to export a site and not include the contents of the site itself
msdeploy -verb:sync -source:apphostconfig=”8aselect” -dest:archivedir=c:\resources\8aselect.zip,encryptPassword=MyPassKey -skip:objectName=dirPath,absolutePath=”d:\\websites\\8aselect”
Command to import a site and skip deleting existing files
msdeploy -verb:sync -source:archivedir=”c:\resources\8aselect.zip”,encryptPassword=MyPassKey -dest:appHostConfig=”8aselect” -skip:objectName=filepath,skipAction=delete