Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007 implementation practically requires moving the content database from one environment to another – from development, to staging, to production. Microsoft has provided us several ways to do this. It could be done using Central Administration facilities, or by STSADM command-line tools. In this piece, I will complete the task using the later approach.
In our source server, let us do the following steps:
1. In the Command Prompt, let us change to the directory where the STSADM command-line tool is located. By default, it is on C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN.
2. The next step is to prepare our content database before moving it by setting up the profile and membership synchronization service. It prevents the synchronization service from failing and losing related settings. To do this, let us type the following command, and then press Enter:
STSADM –o preparetomove –contentdb <content database name>
3. Now, let us detach our content database by executing the command below. We have to take note, however, that removing the content database simply removes the association of the database with our SharePoint Web application and does not exactly delete the database.
STSADM -o deletecontentdb –url <URL name> -databasename <database name> -databaseserver <database server name>
4. Let us open our Microsoft SQL Server 2005 Management Studio, and detach the content database. Finally, we will copy the corresponding .mdf and .ldf files to our destination server.
In our destination server, let us do the following steps:
NOTE: It is assumed that you have created a corresponding Web site in you destination server and deleted its content database – like what we have did in steps 2 and 3. With this, we are now ready to restore/move the content database of our source server to the destination server. Thanks Amlan for the comment.
5. Let us open our Microsoft SQL Server 2005 Management Studio, and attach the content database that we transferred in the previous step.
6. In the Command Prompt, let us change to the directory where the STSADM command-line tool is located. By default, it is on C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN.
7. Now, to add the content database to our destination server, let us type the following command, and then press Enter:
STSADM –o addcontentdb –url <URL name> -databasename <database name> -databaseserver <database server name>
8. And finally let us start a full crawl. We must be aware, moreover, that a full crawl will occur the first time even if the next crawling scheduled is set to incremental mode in the content database we have restored.