Purger la DB de Log de transaction de Sharepoint sous SBS

Xavier Mustin

Administrator
Staff member
#1
I found this KB article http://support.microsoft.com/kb/2000544

In particular, if I run the below script, can I safely change the location for the backups from c:\windows\temp to d:\windows\temp as I don't have enough space on the c drive

Thanks

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

Code:
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=''[B]C:\windows\temp[/B]\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=''[B]C:\windows\temp\[/B]after.bkf''';
execute(@ConfigDBCmd);
go

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

Code:
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.
 
Haut