• Home
  • Consulting
  • Contact Us
    • About this site
    • Contact Wayne
    • Media Room
    • Wayne’s Bio

SBSFAQ.COM

Supporting IT Pro's & MSP's since 2000

  • Blog
  • FAQs
  • Reviews
  • Downloads

How can I reduce my ShareWebDb_log.ldf file size?

September 15, 2011 by Wayne Small 7 Comments

Yesterday you will have seen how I reduced the size of my SharePoint Config Log file on my SBS 2008 server from 10.9GB down to 1MB.  While I was digging, I noticed that the ShareWebDB_Log.ldf file was also quite large at 2.8GB in size.  I thought this was abnormal too – so I modified the script from the Microsoft KB article I found yesterday.

image

Here’s my modified script below

declare @ConfigDB varchar(255);
declare @ConfigDBLog varchar(255);
declare @ConfigDBCmd varchar(255);

select @ConfigDB =  name from sys.databases where name like ‘ShareWebDb%’;

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

‘ShareWebDb_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

I then saved the text above into a log file called ShareWebLogShrink.sql and ran the following command from an elevated command prompt

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

 

Once it was done, my ShareWebdb_log file was down to 1MB once more.  Time will tell how it progresses in the future.

image

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to print (Opens in new window)

Filed Under: FAQs Tagged With: SBS 2008, SharePoint, Windows Sharepoint Services

About The Author

Wayne has been working with Microsoft Server products in the SMB market for over 20 years. He has a passion for technology and been a Microsoft MVP for over 15 years. Read More…

Comments

  1. Lee says

    September 19, 2011 at 3:43 pm

    When i try run your script i get this error.

    Msg 102, Level 15, State 1, Server SBSSERVER\MICROSOFT##SSEE, Line 5
    Incorrect syntax near ‘`’.
    Msg 102, Level 15, State 1, Server SBSSERVER\MICROSOFT##SSEE, Line 7
    Incorrect syntax near ‘`’.
    Msg 102, Level 15, State 1, Server SBSSERVER\MICROSOFT##SSEE, Line 9
    Incorrect syntax near ‘”‘.
    Msg 102, Level 15, State 1, Server SBSSERVER\MICROSOFT##SSEE, Line 12
    Incorrect syntax near ‘`’.
    Msg 911, Level 16, State 1, Server SBSSERVER\MICROSOFT##SSEE, Line 12
    Could not locate entry in sysdatabases for database ” + RTRIM(@COnfigDB) + ”.
    No entry found with that name. Make sure that the name is entered correctly.

    Reply
  2. John K says

    November 9, 2011 at 10:39 am

    Lee: change the quote marks to regular ones, not the angled ones.

    Reply
  3. Eric says

    August 13, 2012 at 12:44 am

    Thanks for this! I was getting warnings about database size while migrating from SBS 2008 to 2011. I did some poking around and realized it was because of this log file. Ran your script, re-ran the preupgradecheck and it stopped complaining.

    Reply
  4. Adam says

    January 8, 2013 at 2:05 am

    Perfect. Was upgrading SBS 2008 to 2011, exact problem, exact solution. Thanks.

    (Remember to change both single and double quotes to the standard unangled ones, using, e.g., notepad and search & replace)

    Reply
  5. Jan says

    February 13, 2013 at 10:15 am

    I’m having the same issues as Lee had. What qoutes marks need to change in other qoute marks.””””””””””“““ or do we have more of them?

    Reply
  6. rbuila says

    October 25, 2013 at 8:45 am

    Perfect I reduce 2 files from 3Gb to 1Mb. SharePoint_Config_773e233a-1a8d-44ff-911b-4d257168aec8_log.LDF and ShareWebDb_log.LDF

    Thanks!!!

    Reply
  7. philip says

    November 16, 2014 at 8:44 am

    worked great , txs !

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Connect Online With Us

  • Facebook
  • Twitter

Reviews

Splashtop – Cost Effective Remote Control Software

September 22, 2017 By Wayne Small 2 Comments

Western Digital DL4100 NAS

March 3, 2015 By Wayne Small Leave a Comment

SBS 2011 Configuring Certification Guide (70-169)

August 7, 2012 By Wayne Small 4 Comments

Site News

Exchange Bug Stops Mail Delivery in 2022

January 2, 2022

Huge bug found in Intel CPU that could permit hackers to steal your data

January 4, 2018

Recent Posts

  • MS Exchange Zero Day and RemotePowerShell Disabling on Admin accounts
  • Setup changes for Exchange 2016 and Exchange 2019
  • Bluetooth Mouse and Keyboard Randomly Stop Responding
  • Exchange Bug Stops Mail Delivery in 2022
  • How to open and search extremely large text log files

Tags

Antivirus Backup Business Focus Cloud Computing Community Conferences Disaster Recovery Exchange 2010 Exchange Server Future Products Hyper-V Installation Microsoft Migration Patches Personal Rants SBS 4.5 SBS 2000 SBS 2000 SP1 SBS 2003 SBS 2003 Premium SBS 2003 R2 SBS 2003 R2 Premium SBS 2003 R2 Standard SBS 2003 SP1 Premium SBS 2003 SP1 Standard SBS 2003 Standard SBS 2008 SBS 2008 R2 SBS 2011 SBS 2011 Essentials SBS 2011 Standard Security Service Packs ShadowProtect SMB Community Software Software I use StorageCraft Training TrendMicro Troubleshooting Virtualisation Windows Server 2012 Essentials

Terms of Use

Privacy Policy

Copyright © 2023 · Magazine Pro Theme on Genesis Framework · WordPress · Log in