Pages

Nov 28, 2011

Sharepoint 2007 - Splitting up a very large Content DB into multiple content DBs


Very Exciting. Getting ready to split up a large content DB on a large enterprise level moss farm deployment. The idea is to distribute data that has grown over time into multiple content databases for performance and reliability. The plan is to use stsadm -o mergecontentdbs. However this is known to have implications and issues - http://support.microsoft.com/kb/969242. We are taking all necessary steps to avoid any problems. I'll update this post later on how our operation does.
 Update - Sorry for the late update guys. heres how it went.
 We had 2 tasks ahead of us. One was to move a content db from one database server to another in the cluster. The other was to split up a large content db on one of the servers into multiple content dbs.
Splitting the large content db into multiple content DB's:
 Microsoft recommended that we do not run the merge content db command on databases larger that 10 GB in size. So instead of moving out the larger site collections into new content databses, we decided to move all of the smaller site collections out instead. This would take much longer, but would be safer so we went that route.
  1. Make sure we stop all search crawls. This is important. Not pause but completely stop the search crawls. Let the running crawls complete and remove the schedule for all future crawls. If we do not do this, we take the risk of corrupting our search indexes.
  2. Create the new content databses
  3. Run stsadm -o preparetomove on the content db to be split
  4. Create a sites.xml using stsadm -o enumsitecollections on the source content database
  5. split up the sites.xml into manageable chunks containing the site colllections that we which to split out
  6. run stsadm -o mergecontent dbs on the source and destination content databases using the site.xml files created in step 5 to move the site collections from source to destination database to the destination content databases
  7. run stsadm -o databaserepair command on the source and destination databses to remove any orphan records - we had none
  8. test
we moved approximately 150 GB of data from a large content database into 5 diffenet new content databases. It took us approximately 18 hours including testing. After the maintennance, we improved page response times for the site collections. We also reduced app pool recycles for our web applications due to processes hitting their virtual memory limits. These almost seemed to dissapear after the maintennance. Overall we were very happy with the results.
Moving a content db from one server to another:
We had multiple large content databases on one server and we wanted to balance it out by moving a large content database from one server to another in the cluster.
  1. Run stsadm -o preparetomove on the content db to move
  2. detach the content db by running stsadm -o deletecontentdb
  3. using sql management studio, detach the content database from the server instance
  4. move the databse files from the source server to the destination server
  5. using management studio, re-attach the content database on the new sql server
  6. add the content database by ising stsadm -o addcontentdb
  7. Test
that was pretty much it. After our maintennance, we started our search crawls and reset the schedule. balancing out the databases also increased performance on our web applications.

Sharepoint 2007 - Poweshell Script to Delete site.


[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Sharepoint”)
$site = New-Object Microsoft.SharePoint.SPSite("http://md1devvmossapp3:15801/")
foreach ($web in $site.AllWebs) {
  try
{
  $web.Delete()   
  $web.Dispose()
  Write-Host $web.Url " : Is deleted"
  }
  catch [System.SystemException]
{
    write-host “Execution stopped due to: “+$_.Message
}
}


Reference : 

Sharepoint Feature Stapling

Back up and Restore your Site Collection in Sharepoint

You can use the tools included with Microsoft Office SharePoint Server 2007 to back up and restore your site collections. The Stsadm command line tool offers a fast and flexible, command line-based approach to content backup and recovery. You can use the Stsadm command-line tool together with Windows Scheduler to schedule delayed or periodic backups.
For more information about how the data protection tools included with Office SharePoint Server 2007 compare with other tools for protecting the SharePoint data, see Choose backup and recovery tools (Office SharePoint Server). 

Important:
If changes are made to the site collection during the backup process, the backup can become corrupted. Backing up large site collections can take a long time. To reduce the chance that user activity will interfere with a site collection backup, or that the time that is required to back up large site collections will exceed the available maintenance window, follow these recommendations:
• For the duration of the backup, set the site collection URL to read-only by using the Setsitelock operation in the Stsadm command-line tool. This lets users view content on the site, but prevents activities such as adding or changing content that interfere with the backup process. When the backup is complete, return the access setting of the site collection URL to its default state.
• If the size of the site collection that you want to back up is 15 gigabytes (GB) or smaller, use the Stsadm command-line tool as shown in the procedures that follow.
• If the size of the site collection that you want to back up is from 15 GB through 100 GB, use Microsoft SQL Server 2005 or Microsoft System Center Data Protection Manager 2007 to perform a full backup of the site collection database.
• If the size of the site collection that you want to back up is larger than 100 GB, use System Center Data Protection Manager to perform a differential backup of the site collection database.
For more information about backup and recovery tools, see Choose backup and recovery tools (Office SharePoint Server).

Back up a site collection by using SharePoint built-in toolsUse this procedure to restrict access to the site collection during backup by using the Stsadm command-line tool.
Important:
Membership in the Administrators group on the local computer is the minimum required to complete this procedure. Limit access to the site collection during backup1. At a command prompt on the drive on which SharePoint Products and Technologies is installed, change to the following directory:%COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.
2. To determine the current access level of the site, type the following command, and then press ENTER: stsadm -o getsitelock -url <> where URL name is the URL of the site collection that you want to back up.
3. If the current access level allows changes to the site content, change it to read-only by typing the following command, and then pressing ENTER:stsadm -o setsitelock -url 
<-lock readonly where URL name is the URL of the site collection that you want to back up.
4. When the backup is complete, reset your site collection lock from read-only to none
stsadm -o setsitelock -url <-lock none

Use this procedure to back up a site collection by using the Stsadm command-line tool.

Important:
 Membership in the Administrators group on the local computer is the minimum required to complete this procedure. To back up a site collection by using the Stsadm command-line tool 1. On the drive on which SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.
2. Type the following command: stsadm -o backup -url 
<-filename <\\server. name\folder name\file name> [-overwrite] where URL name is the URL of the site collection that you want to back up, and where \\server name\folder name\file name is the UNC path of the backup folder and the name of the file that you are backing up to. If there is an existing file for the backup, use the -overwrite parameter to overwrite the existing file.
3. If the backup is completed successfully, the Command Prompt window displays the following text: Operation completed successfully.
4. If the backup is not completed successfully, the Command Prompt window provides additional details about the failure. Most typically, an incorrect URL or file name was given.
Use this procedure to restore a Web application by using the Stsadm command-line tool.

Important: 
Membership in the Administrators group on the local computer is the minimum required to complete this procedure.
 To restore a site collection by using the Stsadm command-line tool 

1. On the drive where SharePoint Products and Technologies is installed, change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin.
2. To restore a site collection, type the following command, and then press Enter: 
stsadm -o restore -url 
<-directory <\\server. name\folder name\file name> -restoremethod overwrite where URL name is the URL of the site collection that you want to restore and UNC path is the UNC path of the backup shared folder.
3. When you receive a warning that all selected items will be overwritten, type y, and then press Enter.
4. When prompted, type the user name and password for the Web application and content databases.
5. If the recovery is completed successfully, the Command Prompt window displays the following text:
Operation completed successfully.
6. If the recovery is not completed successfully, the command Prompt window provides additional details about the failure.

Most typically, an incorrect URL or file name was given.

It is not possible to schedule backups from the SharePoint Central Administration Web site. There is no operation that enables you to automate backups by using the Stsadm command-line tool.

You can, however, automate the process by creating a batch file and then using Task Scheduler in Windows Server 2003 to run the batch file at a specific time. Because performance can be affected when doing backups with the Office SharePoint Server 2007 built-in tools, you might want to schedule your backups for off-peak times such as at night or on weekends.
 

Use this procedure to create a batch file that will run a full backup of your site collection. This procedure assumes that you have already created a shared folder for your backups.
Tip: When using Task Scheduler, make sure that the system date and time on your computer are accurate. To verify or change this information, double-click the time indicator on the taskbar. To create a batch file

1. Click Start, and then click Run.
2. Type notepad, and then click OK.
3. In Notepad, type the following text:
Copy Code

@echo off
echo ===============================================================
echo Back up sites for the farm to C:\backup
echo ===============================================================
cd \Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
@echo off
stsadm -o backup -directory <\\server name\folder name> -backupmethod full -item 
echo completed
4. where \\server name\folder name is the UNC path of the backup folder and where Web application name is the name of the site collection that you want to back up. You might use the full farm path notation as displayed by the showtree parameter or the name of the component in the path if it has a unique name — for example, Windows SharePoint Services Web Application\SharePoint-80.5. In Notepad, on the File menu, click Save As.6. In the Save As box, select the folder where you want to keep your batch file.7. Use the ".bat" file name extension; type the name of the file in the File name box, for example, backup_batch.bat.8. In the Save as type box, click All files.9. Click Save.
To schedule a backup 
1. Start the Scheduled Task Wizard, and then click Next.
 
2. Click Browse, locate the batch file that you just created, and then click Open.
 
3. Type a name for your task, for example, backup_batch.
 
4. Select how often you want this task performed (for example, weekly), and then click Next.

5. To automatically perform this backup periodically, select an interval such as Weekly or Monthly. To perform this backup one time, or to delay a single backup, select One time only.
6. Choose a time and start date for your backup.
7. Type a name and password for a user, and then click Next. This task will run as if it were started by that user. 
8. Click Finish.
To configure advanced settings for the task, select the Open advanced properties for this task when I click Finish check box in the final page of the wizard. This opens the properties dialog box for the task when you click Finish.

You can then change the program being run on the Task tab, fine-tune the schedule on the Schedule tab, customize settings on the Settings tab, or set user and group permissions on the Security tab.

Courtesy: MSDN