Alexander's Blog

Sharing knowledge with the global IT community since November 1, 2004

How to Use STSADM to Import/Export a SharePoint Subsite

/
/
ad-mania

The STSADM tool allows you to import and export SharePoint sites by specifying STSADM -0 Import and STSADM -o Export. The Import/Export options are ideal for backing up and restoring subwebs. To backup and restore entire site collections use STSADM -o Backup and STSADM -o Restore options.

Let’s say you want to backup a Demo subsite at http://www.contoso.com/demos and restore it to a different site at http://www.example.com/demos. You can use the following method to export the demo site and then restore it to the intended destination. If you want to preserve permissions use the -includeusersecurity switch.

First, make sure STSADM is on your path so you can run it from any directory you want. Otherwise, run it from its default location at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN.

EXPORT SUBSITE

To export the subsite use the following syntax at the Command Prompt. Open the Command Prompt on the SharePoint server as an administrator if necessary.

C:\>stsadm -o export -url http://www.contoso.com/demos -filename DemoSiteBackup –includeusersecurity

You will see a single file called DemoSiteBackp.cmp that includes the exported content. You will also see a log file called DemoSiteBackup.export.log.

TIPJust to make things easier, you might want to create a folder, like C:\SPBackups. Run the STSADM from that folder so the export file (DemoSiteBackup.cmp in our example) and the log file will be created in the same folder.

IMPORT SUBSITE

Now to import the subsite to a different site use the following syntax at the Command Prompt. Open the Command Prompt on the SharePoint server as an administrator if necessary.

C:\>stsadm -o import -url http://www.example.net/demos -filename DemoSiteBackup.cmp -includeusersecurity

Notice that this time you need to provide the filename extension, which is .cmp. You should see the Demo site show up as a subsite in the destination site after the script has been successfully executed. You will also see a log file called DemoSiteBackup.cmp.import.log.

If you need to explore other import or export options, type stsadm -help import or stsadm -help export to see the complete syntax. For example:

 C:\>stsadm -help import

stsadm.exe -o import
           -url <URL to import to>

           -filename <import file name>

[-includeusersecurity]

[-haltonwarning]

[-haltonfatalerror]

[-nologfile]

[-updateversions <1-3>

1 – Add new versions to the current file (default)

2 – Overwrite the file and all its versions (delete then insert)

3 – Ignore the file if it exists on the destination]

[-nofilecompression]

[-quiet]

 

 


Copyright ©2009 Zubair Alexander. All rights reserved.

  • Facebook
  • Twitter
  • Linkedin

4 Comments

  1. Does the folder need to be created in C: drive as soon as command prompt is opened? If not where?

  2. JC,
    You can create a folder ahead of time, or create it at the command prompt (e.g. MD SPBackups). Run the STSADM from that folder (e.g. CD \SPBackups and then run the command) so the export file (DemoSiteBackup.cmp in our example) and the log file will be created in the same folder (e.g. SPBackups).

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar