Optimal SQL Server Recovery Model for SharePoint Databases: Best Practices and Considerations


4 views

When configuring SQL Server for SharePoint deployments, one critical decision is choosing between the three recovery models:

  • Full Recovery: Maintains complete transaction logs, enabling point-in-time recovery
  • Bulk-Logged: Minimally logs bulk operations while maintaining other transactions
  • Simple Recovery: Automatically truncates transaction logs, only supporting full backups

For most SharePoint implementations, Simple recovery model provides the best balance:

-- Example SQL to check current recovery model
SELECT name, recovery_model_desc
FROM sys.databases
WHERE name LIKE 'SharePoint_%';

Key advantages include:

  • Reduced storage requirements (transaction logs don't grow uncontrollably)
  • Simplified maintenance (no log backup scheduling needed)
  • Better performance for typical SharePoint operations

Exceptions where Full recovery might be warranted:

-- Example of changing to Full recovery
ALTER DATABASE [SharePoint_ContentDB]
SET RECOVERY FULL;
GO

Scenarios include:

  • Regulatory requirements mandating point-in-time recovery
  • Critical financial data where minimal data loss is required
  • When using SQL Server log shipping or Always On Availability Groups

For Simple recovery model deployments:

-- Recommended backup script for Simple recovery
BACKUP DATABASE [SharePoint_ContentDB] 
TO DISK = 'E:\Backups\SharePoint_ContentDB_Full.bak'
WITH COMPRESSION, STATS = 10;
GO

Best practices:

  • Schedule full backups during low-usage periods
  • Combine with SharePoint's native backup capabilities
  • Consider third-party item-level backup solutions
  • Monitor database growth patterns

Example recovery process with Simple model:

-- Restore from full backup
RESTORE DATABASE [SharePoint_ContentDB]
FROM DISK = 'E:\Backups\SharePoint_ContentDB_Full.bak'
WITH REPLACE, RECOVERY;
GO

Remember that:

  • You'll lose all changes since last full backup
  • Test restores should be performed regularly
  • Document your recovery procedures

When configuring SQL Server for SharePoint deployments, the recovery model selection significantly impacts both performance and disaster recovery capabilities. While the simple recovery model is often suggested for SharePoint databases, the decision requires careful consideration of your specific requirements.

SQL Server offers three primary recovery models:

  • FULL: Captures all transactions, enabling point-in-time recovery
  • BULK_LOGGED: Minimally logs bulk operations while maintaining other transactions
  • SIMPLE: Automatically truncates transaction logs, limiting recovery options

For most SharePoint databases, simple recovery makes sense because:

-- Sample SQL to check/set recovery model
SELECT name, recovery_model_desc 
FROM sys.databases 
WHERE name LIKE 'SharePoint_%';

ALTER DATABASE [SharePoint_ContentDB] 
SET RECOVERY SIMPLE;

The recommendation stems from SharePoint's architecture where:

  • Content databases typically don't require point-in-time recovery
  • SharePoint's own backup solutions handle item-level restoration
  • Transaction logs can grow excessively with FULL recovery

Exceptions where FULL recovery might be justified include:

-- Scenario: Mission-critical databases needing point-in-time restore
ALTER DATABASE [SharePoint_ConfigDB] 
SET RECOVERY FULL;
  • Configuration databases where changes are infrequent but critical
  • Environments without third-party backup solutions
  • Special compliance requirements mandating transaction logging

For a balanced approach:

-- PowerShell script to configure recovery models appropriately
$contentDBs = Get-SPDatabase | Where-Object {$_.Type -eq "Content Database"}
foreach ($db in $contentDBs) {
    Invoke-Sqlcmd -Query "ALTER DATABASE [$($db.Name)] SET RECOVERY SIMPLE;"
}

Regular verification is crucial:

-- Create a SQL Agent job to check recovery models weekly
USE [msdb]
GO
BEGIN
    DECLARE @RecoveryCheck TABLE (DBName NVARCHAR(128), RecoveryModel NVARCHAR(60))
    INSERT INTO @RecoveryCheck
    EXEC sp_msforeachdb 'SELECT ''?'' AS DBName, DATABASEPROPERTYEX(''?'', ''Recovery'') AS RecoveryModel'
    
    SELECT * FROM @RecoveryCheck 
    WHERE DBName LIKE 'SharePoint%' 
    AND RecoveryModel != 'SIMPLE'
END
GO

In practice, I've found that:

  • SharePoint's native recycle bins handle 95% of recovery needs
  • Third-party solutions outperform SQL log restores for granular recovery
  • Simple recovery significantly reduces storage overhead with no practical downsides