SBS 2008 Sharepoint log files worden te groot.

Vraag:

The Windows SharePoint Services 3.0 (WSS 3.0) log file may grow to a large size on a default installation of Small Business Server 2008 (SBS 2008). The SBS 2008 Best Practices Analyzer (BPA) will report a warning message with the text:

Sharepoint Config database log file getting large

The Windows SharePoint Services configuration databases log file is getting large (currently over 1gb in size)
Tags: sharepoint, database, big, size, log file

Antwoord:

To reduce the size of the log file, use the following steps. A full server backup is recommended first.

1. Open notepad and Copy and paste the following text into notepad. Save the file as c:\logshrink.sql

declare @ConfigDB varchar(255);
declare @ConfigDBLog varchar(255);
declare @ConfigDBCmd varchar(255);
select @ConfigDB = name from sys.databases where name like ‘SharePoint_Config_%’;
set @ConfigDBCmd = ‘BACKUP database [‘ + RTRIM(@ConfigDB) + ‘] to disk=”C:\windows\temp\before.bkf”’;
execute(@ConfigDBCmd);
set @ConfigDBCmd = ‘use [‘ + RTRIM(@COnfigDB) + ‘]’;
execute(@ConfigDBCmd);
set @ConfigDBCmd = ‘BACKUP LOG [‘ + RTRIM(@ConfigDB) + ‘] WITH TRUNCATE_ONLY’;
execute(@ConfigDBCmd);
set @ConfigDBCmd = ‘use [‘ + RTRIM(@COnfigDB) + ‘]’;
execute(@ConfigDBCmd);
select @ConfigDBLog = name from sys.database_files where name like ‘SharePoint_Config%_log’;
set @ConfigDBCmd = ‘use [‘ + RTRIM(@ConfigDB) + ‘] DBCC SHRINKFILE([‘ + RTRIM(@ConfigDB) + ‘_log],1)’;
execute(@ConfigDBCmd);
set @ConfigDBCmd = ‘BACKUP database [‘ + RTRIM(@ConfigDB) + ‘] to disk=”C:\windows\temp\after.bkf”’;
execute(@ConfigDBCmd);
go

2. Open an elevated command prompt and run the following command:

sqlcmd -S \\.\pipe\mssql$microsoft##ssee\sql\query -E -i c:\logshrink.sql

This script will create two backup files (before.bkf and after.bkf) in C:\windows\temp.