How to copy SharePoint Site and its Content to Another Site
This is very important information. Because whenever you need to deploy something from your development environment to test or production environment, you will either use save site as template, which i never successfully did it , or you use following Powershell commands. It is very easy and i myself use all the time.
Remember! Powershell command can be use only at server that your sharePoint installed . Therefore, to do this action you have to have authority to access the server or you have to let server admin to do the job.
Before you start, you must create the site that you will copy lists and contents.
SharePoint 2010 Management Shell which you find at Start -> All Programs -> Microsoft SharePoint 2010 Products.
Execute power shell and to export site write this command:
then powershell ask you identity. write downthis site url like http://sp2010/sites/mytestsite. Next it will ask you path, this this path of file that we will export content into. Write like C:\export.bak
when you hit the enter after a while you will see the export.bak file at C drive.
-> Export-SPWeb -Identity <Site Path> -Path <cmp File path>
For example: Export-SPWeb -Identity http://sp2010/sites/mytestsite -Path C:\export.bak
To import same procedure but different powershell command:
-> Import-SPWeb -Identity <Site Path> -Path <cmp File path>
For example: Import-SPWeb -Identity http://sp2010/sites/myimportsite -Path C:\export.bak
then powershell ask you identity. write downthis site url like http://sp2010/sites/myimportsite. Next it will ask you path, this is the path of file that powershell will use to import content. Write like C:\export.bak
when you hit the enter after a while you will see that all list and its content there.
Honestly this is the most useful trick i have learned about SharePoint.