First Time Deployment in the Production Environment using Script | Move sites between Production and Development Environment | Content Deployment using STSADM
We can do SharePoint 2007 deployment from the Central Administration and using STSADM.exe but most of the administrator prefer to work using stsadm.exe command. It is necessary to remember the command and do the same steps every time. Most of them want to get a batch deployment script or something easier to do it using stsadm.exe command. This article will show how to make own customize deployment script bat file and simple way to deploy it. You have to make package folder before going to following stepsater. Let’s see the steps first:
1. Copy Package i.e. Deploy Folder in to C: Drive
Open Command Prompt and go to C:\Deploy
2. Run Export_Site.bat [Site URL i.e. http://[server1: port]/sites/test1]
It will export the website in the following location C:\Deploy\Export.cab
3. Run Create_Site.bat [New Site URL]
i.e. C:\Deploy>Create_Site http://[server2: port]/sites/test1
To Create a new site as source site type in existing Web Application
4. Run Import_Site.bat [New Site URL]
i.e. C:\Deploy>Import_Site http://[server2: port]/sites/test1
It will import the website from the following loc C:\Deploy\Export.cab
If you have some features has been deployed before in the source site such as custom web part or event receiver or list definition then you have to do the following steps before running import_site.bat
- Run for each deployment
C:\Deploy>[Folder Name]\setup -install -siteurl [New Site URL i.e. http://[server2: port]/sites/test1]
To Install and Deploy List Definition, Event Receiver
How to make Deploy Package and bat script file:
@echo off
if not "%1"=="" goto ExportImport
echo **** put web site name for emample: "http://server:port/sites/areri"
goto end
:ExportImport
echo ************* Determine the Location to stsadm.exe
if EXIST "%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\bin\stsadm.exe"
set BinDir=%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\bin
echo Determined that the location to stsadm is %BinDir%
@echo on
@echo ************* Backup the root site collection
"%BinDir%\stsadm.exe" -o export -url %1 -filename C:\Deploy\Export.cab -versions 4 -overwrite
@echo off
:end
Create Create_Site.bat --> change with the previous part
@echo on
@echo ************* Create a destination site (-lcid 1033 for en, -sitetemplate)
"%BinDir%\stsadm.exe" -o createsite -url %1 -ownerlogin %UserDomain%\%UserName%
-owneremail %UserName%@credem.it -lcid 1033 -sitetemplate STS
Create Import_Site.bat --> change with the previous part
@echo on
@echo ************* Import into the new site
"%BinDir%\stsadm.exe" -o import -url %1 -filename C:\Deploy\Export.cab
Put all in the Deploy Folder for simple deployment otherwise put others sub packages (web part, even receiver etc.) and that’s it
Reference:
http://msdn.microsoft.com/en-us/library/aa979099.aspx