Alexander’s Blog

February 12, 2009

How to Use STSADM to Import/Export a SharePoint Subsite

by @ 7:18 pm. Filed under Articles, Scripting, SharePoint, Tips & Tricks

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.seattlepro.com/demos and restore it to a different site at http://www.techgalaxy.net/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.seattlepro.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.techgalaxy.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.

Contact E-mail | Terms of Use | Privacy Policy

Copyright © 2013 Zubair Alexander. All rights reserved.

Internal Links

Search Blog

Categories

Archives

February 2009
M T W T F S S
« Jan   Mar »
 1
2345678
9101112131415
16171819202122
232425262728  

RSS Feeds

TechGalaxy Visitors

24 queries. 0.471 seconds