My new blog

My blog has moved to www.davehunter.co.uk/blog see you there.

Thursday 5 July 2007

STSADM Import / Export

STSADM has two operations called "import" and "export".

Export allows you to backup a copy of a site to the file system. This will generate one or more .CMP files (based on the size of the site, this will distribute the contents over many .CMP files).

Import allows you to take the files generated by an export and import over a blank SharePoint Site.

Please note: Both Import and Export operations for STSADM deal with an entire site. You can not export or import individual items such as lists or items.

I used Import / Export during a migration to restructure the sites. Basically I had a collection of WSS sites for active projects and a collection of WSS sites for archive projects which weren't logically organised. I wanted to introduce a level for the active projects and another level for the archive projects. I created these levels (active and archive) in SharePoint through the standard create site function. I then need to move the archived sites under archive and active under the active site. This process is often referred to a re-parenting. I did this using STSADM and the Export operation and the Import operation (see below).

STSADM -o export -url http://localhost/ProjectSite1 -filename c:\export\ProjectSite1 -includeusersecurity
STSADM -o createweb -url http://localhost/Archive/ProjectSite1
STSADM -o import -url http://localhost/Archive/ProjectSite1 -filename c:\export\ProjectSite1.cmp -includeusersecurity

Please note: By using the parameter "includeusersecurity" it preserves the current user, rights for the site. This is an optional parameter, but very useful.

The createweb operation creates a blank site for the import to write the contents of the export over. You shouldn't specify a sitetemplate as you just need a blank container (the template is defined in the export .CMP files).

STSADM is a command line tool, so you could wrap these commands in a batch file.

Please see my post about errors when using the Import / Export commands here.

No comments: