Moving site collections between Content databases with a single command

When I first heard about it, I had to test the simplicity to do this with the new stsadm option that was inserted in the latest security hotfix for WSS of October 9th. This command is not very well documented anywhere. I herad about it by Todd Klindt in one of his TechEd sessions last week and tested it today. I must say it works like a charm.

This is the command: 

stsadm.exe -o mergecontentdbs
           -url <url>
           -sourcedatabasename <source database name>
           -destinationdatabasename <destination datbabase name>
           [-operation <1-3>
                1 – Analyze (default)
                2 – Full Database Merge
                3 – Read from file]
           [-filename <file generated from stsadm -o enumsites>]

See also:
     stsadm -o enumcontentdbs -url <url>
     stsadm -o enumsites -url <url> -databasename <database>

The way this is to be used as suggested by Todd is, to use a file with the site collections you want to move. As you can see above this file can be generated by the stsadm -o enumsites command. All you need to do then, is open up the file and remove the lines with the site collections you do not want to move. Save the rest and feed it to the new command.

e.g. C:\stsadm -o mergecontentdbs -url http://wss -sourcedatabasename WSS_Content_7fc30dd3c1514cdda6b68bd8d10a0463 -destinationdatabasename WSS_Content -operation 3 -ilename sites.txt

So, I hope you enjoy this cool new command and use it !

Update 20 Nov ’07: Todd has finally found the time to publish his article about this as he promised at TechEd. Go check it out @

Leave a Reply

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