Tuesday, September 21, 2010

Move SharePoint Site/Web From One Development Server to Another

Sometimes, we need to move the site from one server to another, usually in development environment. In that case its required few steps to make sure you have moved your site in new server. I have successfully move my sites and I’m pointing here the exact steps that worked for me.

  • Backup the site or export the web

First of all you need to take backup of the site (if you want to move site collection). If you want to move a single site then export the web contents. For site backup use the following command:

Backup-SPSite -Identity http://MySiteColllection.com -Path "C:\Backup\BackupFile.bak" -Confirm:$false

For exporting web use the following command.

Export-SPWeb –Identity http://MySiteCollection.com/myweb –Path “C:\Backup\BackupFile.cmp” –Confirm:$False

For more on these commands follow MSDN link.

 

  • Create Dummy site or web on the destination server to overwrite

Before restoring or importing site/web you need to create a dummy site/web on the destination server. In case of site restore, create a new site collection. In case of web import, create a site with the same name and template used in source server’s web.

 

  • Deploy code on the server

If possible, then deploy the sharepoint solution (generated from your developer code in Visual Studio) on the destination server. In some case the restore/import operation looks for features/resources on the site/web that is referenced in the backup/export file. So deploying the code on the server make sure the code (that will be finally used in the restored site/web) is on the destination server. If your code has web level feature/resources then use the root web as the default one to deploy code.

 

  • Restore or import the site/web

Finally you are ready to restore the site. Run the following command to restore a site collection.

Restore-SPSite -Identity http://MyNewSiteCollection.com -Path "C:\Backup\BackupFile.bak" -Confirm:$false -Force

Run the following import command to import site.

Import-SPWeb –Identity http://MyNewSieCollection.com/MyNewWeb –Path “C:\Backup\BackupFile.cmp” –Overwrite –Confirm:$False

For more on these commands follow MSDN link.

 

  • Check user Permissions

If you restored a site collection then you need to change site collection administrator as the restored site is still pointing to the old site collection administrators (and maybe the administrator is invalid in the new server). From SharePoint central administration site change the site collection administrator to proper one.

 

Few points to notice

When you move the site/web few points need to remember:

  • If you restore just a web then your import operation may fail saying a feature is not installed on the web/site. This may happen in case where the source site /web’s backup file is referring a resource (say feature) that is not available on the destination server. In this case, make sure your code is deployed properly on the destination server. If you get the error for a particular web, then create a dummy web with the same name as on the source server, on the destination server and then deploy the code on the web and finally try to restore the web.
  • In case of web import, make sure you have created the new web on the destination server with the same template. You can’t overwrite a web on destination server with a source one that is using different template.

11 comments:

  1. how about this one
    http://www.turhaltemizer.com/2010/11/move-sharepoint-siteweb-from-one.html

    ReplyDelete
  2. If somebody copy my blogs, what I can do? its not a problem if somebody uses content from another but its not professional to copy word by word and not to refer the original blog...

    ReplyDelete
  3. Great find, I’m going to have to check this one out. Thanks for sharing.
    Very informative….

    ReplyDelete
  4. what's the difference between the stsadm version and powershell version?
    some person said that Microsoft didn't recommend this command to move to another server, as this will cause some (minor) problem. Is it true in ur point of view?

    ReplyDelete
  5. stsadm is pre-SharePoint2010. For SP2010, powershell is recommended. Also powershell is more rich for writing scripts.

    ReplyDelete
  6. if i have some custom features, than how to import them in new server?

    ReplyDelete
  7. The features association with sites/webs/farm will be imported along with content database. However, you need to deploy the wsp solution to the destination server before using the updated site.

    ReplyDelete
  8. Its important for sharepoint developers to know about this movement and how to do it. It is quite an important process....

    ReplyDelete
  9. @Nakul, The way you are commenting is spamming. Please don't do this. I already marked your previous message as spam. If people continue marking your messages as spam, your email will be marked as spam email very soon. If you have relevant questions or suggestion please share it.

    ReplyDelete
  10. hi,
    assume that i have taken the backup/restore or export/import the site from Dev server to PROD envmnt and its deployed and is in live.
    aftr few days, customer wants addiitonal functionality like adding 10+ site pages and ce wp, cqwp, annoucnements etc and assume that i dont have access to the prod. how can i deploy this updated site from dev to prod?

    ReplyDelete
  11. @prasad, You can automate the changes using PowerShell/Feature Receiver. Though creating pages, adding webparts are more like administrative tasks instead of developer tasks, however you can write script/code to automate the task and deliver client the script/package to deploy.

    ReplyDelete

Note: Only a member of this blog may post a comment.