How to backup and restore (migrate) a single sub site (of a SharePoint Site Collection) using STSADM –o export (and import)

Ok, long title but I wanted to be as descriptive as possible…




I had need today, as I often do, to help a client ‘clean up’ their SharePoint environment. They wanted a new SharePoint site (built on a sound infrastructure, etc. – my favourite) but wanted to bring across ‘some’ of their old content. In this case, there was a sub site that they wanted to bring across in its entirety, with as much version history as possible. The Solution? STSADM –o export


I’m going to outline the process here, of the steps I had to perform (and the pratfall I discovered, re: STSADM and it not liking cut and paste from other sources/references resulting in ‘Command Line Error’ being returned – which in turn, turned out to be because the example syntax I was cutting and pasting from was using the wrong character format for the “-” (dash) character. Once I addressed that (thanks, in hints from:, I was back on my way to finishing the task). So here goes…


The Requirement

Backup a sub site of an existing site collection, with security information and version history retained from one SharePoint Server Farm (not the entire site collection, as you would use –o backup for that, see my ‘sandbox’ refresh post here), to another. In my case, I’m able to bring the Security information across as they exist in the same domain. Note: You will want to avoid the “-includeusersecurity” command, if you going beyond the domain.


The Solution

STSADM –o export followed by STSADM –o import (and the appropriate syntax, see example below). Here is a nice, syntax overview for quick reference.


The Example

Note, all commands assume you can use the STSADM command (have it in your path, or have put yourself in the appropriate directory to run it – c:program filescommon filesmicrosoft sharedweb server extensions12bin.


Export Syntax Example

stsadm -o export -url http://nfn-spsrv:23651/sites/nfnentportal/treaty -filename “c:swexporttreatysubsitebackup” -includeusersecurity -versions 4


The above is indicating that I am:

  • Exporting the following site: http://nfn-spsrv:23651/sites/nfnentportal/treaty
  • Exporting to files in the following directory: c:swexport (Sean Wallbridge Export, my own little folder)
  • Prefix all files with treatysubsitebackup
  • Including User Security
  • Maintaining all version history by choosing option 4 (reference below for all version settings)
    • 1   Directs the import operation to add new version specifiers to the current file (default).
    • 2   Directs the import operation to overwrite the file and all of its versions (delete file, then insert file).
    • 3   Directs the import operation to ignore the existing file.
    • 4   Directs the import operation to terminate the import operation if file conflicts are detected.


And the resulting backup looks like this…


Import Syntax Example

Cool, I’ve got my site exported; now it’s time to plunk it into the new site. The first step is to create an empty sub site, using the standard approach (note, you do not need to create the initial site, I just like to for my own nervous reasons ;):



Finally, run the import command (quick reference here)…

stsadm -o import -url http://nfn-spsrv:23649/treaty/treatyarchive -filename “c:swexporttreatysubsitebackup.cmp” -includeusersecurity -updateversions 2


Check your log file when it is done, to ensure it went successfully.


  • In the Import command, even though we didn’t specify a file extension with the Export command, you’ll need to add ‘.cmp’ to the end of your Import filename path
  • Also, the versions flag is different, it is ‘-updateversions’ and the numbered option to choose, will be different, depending on your scenario (below is a quick reference):
    • 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]










2 responses to “How to backup and restore (migrate) a single sub site (of a SharePoint Site Collection) using STSADM –o export (and import)

  1. This was extremely helpful and got me many brownie points at work after someone deleted a sub site.

    Thanks very much for posting this.

Comments are closed.