SharePoint Config database Log file too big – reduce it!

October 31st, 2008 | Categories: SharePoint, SharePoint administration

SharePoint Config database logs are one thing to keep an eye on since they do have a tendency to grow. If you don’t perform a full farm backup usually the log doesn’t get emptied and it just keeps bloating.

If you’re running SQL Server Express with default installation, you can find the files in C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData

image

As we see in the example above, even though the database is only 6 megs, the log file grew to 11 gigs. Let’s reduce that:

1. If you don’t have it yet, download and install SQL Server Management Studio express from here.

2. Run the Management Studio and connect to your SQL Server.

3. Expand “Databases” and select your config database “SharePoint_Config”.

4. Right Click it, select Tasks –> Shrink –> Files

image

5. In the new window select Release unused space and click OK.

image

If that doesn’t decrease the database size much, do the following:

1. First to be on the safe side, let’s back it up (this step is optional)

Select New Query



type the following:

BACKUP LOG [Sharepoint_Config] TO DISK=’D:configLogBackup.bak’
GO

where SharePoint_Config is the name of your config database file and D:configlogbackup.bak is the location and file name of where you’ll make the backup.

And click Execute

image

This may take a while if your log file is big.

2. Next clear the query (or click New Query again) and enter the following commands

BACKUP LOG [Sharepoint_Config] WITH TRUNCATE_ONLY
USE [SharePoint_Config]
GO

anc click Execute again

image

3. Clear the query or open another query tab and enter the next command:

DBCC SHRINKFILE (N’SharePoint_Config_log’ , 50)
GO

The 50 in the command above sets the size in MB to truncate the log to. If your config db is of different name, replace the SharePoint_Config part above with your config db name.

And click Execute yet again.

image

The result you get should be something like below:

image

and ofcourse the file size:

image

ahhh. finally some space.

Oznake ponudnika Technorati: ,

  1. October 31st, 2008 at 10:01
    Reply | Quote | #1

    A friend of mine just emailed me one of your articles from a while back. I read that one a few more. Really enjoy your blog. Thanks

  2. Boris Gomiunik
    October 31st, 2008 at 10:09
    Reply | Quote | #2

    Thanks, Sue! I hope it’s helpful :)

  3. Jay
    November 12th, 2008 at 02:07
    Reply | Quote | #3

    Hi, I still am running Sharepoint with the SQL Express version. How can I shrink it as it is not in SQL 2005 yet.
    Any help would be of great assistance.

  4. Boris Gomiunik
    November 13th, 2008 at 10:09
    Reply | Quote | #4

    Hi, Jay!

    The process is the same. These screenshots were even made on a server with SQL Express. All you probably need is to download and install the SQL Server management studio express (the direct link to download can be found in step 1.

  5. November 22nd, 2008 at 08:47
    Reply | Quote | #5

    In SQL Server 2005 where the Sharepoint_Config Database is located?. Because we cannot find any Database like this.
    Our problem is Sharepoint_Config_log file size is 85GB we want to reduce the size of the database.

  6. November 27th, 2008 at 09:09
    Reply | Quote | #6

    Hi, Sankar M.

    You can do a file search in your server. Just look for the database name (SharePoint_config) and it will find. In my case the files are stored in C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData

    • January 23rd, 2009 at 21:21
      Reply | Quote | #7

      I'm glad it helped. It should also work for the content log file. Anyway just to be on the safe side, make a backup of the log file before making changes to that one. :)

  7. Eric
    January 22nd, 2009 at 21:36
    Reply | Quote | #8

    Great article. This worked perfectly. One question, does the same hold true for the other databases? My WSS_Content_log file is 2 gigs.

    Thanks

  8. March 16th, 2009 at 05:47
    Reply | Quote | #9

    Many thanks

  9. Paul
    April 15th, 2009 at 17:55

    I tried this exact process, and my database didn't shrink at all. Mine is almost three gigabytes and I wanted to reduce it to 50megs. It's still at 3 gigs. The script executed with out error and gave me a similar display you have in your example above. What gives?

  10. Dan
    May 8th, 2009 at 15:22

    Went from 12GB to 50MB. Works like a charm. Thanks for the help!

  11. June 19th, 2009 at 04:43

    For those having the same problems I had, when you make:

    BACKUP LOG [Sharepoint_Config] TO DISK=’D:configLogBackup.bak’

    If you receive the error "Cannot open backup device 'D:configLogBackup.bak'. Operating system error 5(Access is denied.)" it is because you must add the user that is currently running the database service with full access to the folder or drive where you are dropping the backup. I had this problem and had to read a little more before getting the solution, so I hope you can get it right here. ;)

    Nice guide, thought! Great one!

  12. Kuba
    July 23rd, 2009 at 11:34

    Excelent quide. Thank you.

  13. Solid
    July 27th, 2009 at 19:51

    HI. I got an error on the messages tab saying: Cannot shrink log file 2 (SharePoint_Config_6af1f30d-5a83-4560-a574-8a332fdfbe21_log) because all logical log files are in use.
    How do I go around this? Thanks a lot.

  14. LT
    August 6th, 2009 at 22:39

    If I’ve used the default WSS 3.0 install with the Express, why can’t I connect to the database with Studio Express? I’ve tried all of my administrator accounts (windows authentication) on that particular server and I always end up with the message “Cannot connect to ServerxxMICROSOFT##SSEE. “An error has occured while establishing a connection to the server. Wehn connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections…………………. error:26 – Error Locating Server/Instance Specified)……………”

    Any suggestions? I need to be able to reduce my log file before I run out of disk space.

    Thanks so much for the articles!!

    • Tan
      August 30th, 2010 at 10:21

      Hi, I had this problem. Paste this into the server name field:

      \.pipeMSSQL$MICROSOFT##SSEEsqlquery

      It should then connect.

  15. Boris Gomiunik
    August 13th, 2009 at 22:05

    Did you install it to sql server express or Windows internal database (SSEE)? SSEE is a very limited database. Have you tried accessing it with SQL Server Management Studio?

  16. Omar Ruiz de Huidobro
    September 22nd, 2009 at 15:50

    Hi Boris.
    Your process worked really fine, and solved my space problem.

    What do you suggest for scheduling those tasks, in order to avoid executing them manually?

    Thanks and regards.

  17. Drew
    October 14th, 2009 at 05:14

    Thanks, great post! Just what I needed.

  18. pryank
    October 20th, 2009 at 13:08

    Hi,
    Hi,

    I am facing some issues while doing SharePoint_Config Database transaction log backups:

    Database LDF file size has grown to 21.xx GB. To truncate the log file I have created a Maintenance plan to backup log (as per MSDN :http://technet.microsoft.com/en-us/library/cc811604.aspx) , but it failed with following message:

    BackupMedium::ReportIoError: write failure on backup device ‘E:BACKUPSSQLTransactionLogsSharePoint_ConfigSharePoint_Config_backup_200910201120.trn’. Operating system error 112(error not found).

    I tried following command manually also using T-SQL as mentioned in this article, but same result. Any ideas??

    Thanks

    Pryank

  19. pryank
    October 20th, 2009 at 13:10

    to give more info: Disk free space is 8.35 GB on backup drive.

  20. Mike G
    October 20th, 2009 at 21:58

    Hello
    I get a message: Cannot shrink logfile 2 (Sharepoint_Config…) because all logical log files are in use.

    What does this mean? Both processes (Shrink -> File) and the SQL command apprear to be successful without error.
    Thank you

  21. Salil Mahajan
    November 9th, 2009 at 23:11

    Thanks a lot !! I can breathe freely now !!!

  22. Srikanth
    November 30th, 2009 at 06:34

    really superb explanation :) thanks you saved me

  23. Jimmy
    December 2nd, 2009 at 08:03

    Very useful. Thank you.

  24. December 8th, 2009 at 20:33

    Just encountered this problem, we followed MS suggestion to reduce and worked okay. My question is how do we keep it in check. You said something about “if you don’t perform full farm backup” Does this help keep the file from growing out of control?

  25. February 2nd, 2010 at 16:09

    Thanks, very good clear article, my log file went from 97Gb to 1 Gb, now thats a space saving!

  26. Amauri
    February 6th, 2010 at 15:26

    Hi, I happen to have a configuration file that is 74 GBs. But cannot find the file under SQL 2005 Management Studio. The file is in a weird location (c:windowssysimetc…dataconfiguration file… how do I find the database under SQL MAnagement Studio? Thanks,

  27. Amauri
    February 6th, 2010 at 15:31

    by the way, this SBS 2003 R2 and the databse refers to a site called intranet. Companyweb works fine.

  28. Andrew
    February 19th, 2010 at 02:10

    I tried both solutions and both didn’t work. The second method threw an error message

  29. Boris Gomiunik
    February 21st, 2010 at 12:43

    @Andrew: Which was the error message?

  30. Haas
    February 23rd, 2010 at 19:04

    At the schrinkfile command is give an error:

    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near ‘’’.

    What is wrong?

  31. Boris Gomiunik
    March 1st, 2010 at 20:14

    @Haas:Please check if you’re using normal single quotes. Copy-paste from this place might copy wrong quotes.

  32. James
    March 11th, 2010 at 18:07

    Absolutely wonderful, accurate, and needed post. Thank you.

    I had ignored my SharePoint_Config file size and it grew to eat up virtually all remaining disk space. The schnifty right-click method didn’t work, but the method involving the 3 queries worked WONDERFULLY.

    To re-ask Omar Ruiz de Huidobro’s question, what is the recommended method of scheduling this? A sproc with fired from a scheduled task?

    -James

  33. March 15th, 2010 at 17:50

    I have the problem of connecting to the database like LT said. My MICROSOFT##SSEE is a windows internal. How do I access this and decrease the size. Thanks for any help

  34. Boris Gomiunik
    March 16th, 2010 at 09:22

    @Jerry: Have you tried installing Sql Server Management studio express? You can find it here:
    http://www.microsoft.com/downloads/details.aspx?familyid=08E52AC2-1D62-45F6-9A4A-4B76A8564A2B&displaylang=en
    This will install only management studio without another instance of SQL server.

  35. Matt Rap
    March 31st, 2010 at 19:36

    I just wanted to say how helpful this article was for me. Thank you very VERY much for taking the time to write this.

  36. Julie from Tallahassee
    April 13th, 2010 at 17:11

    Yes! Now we can breathe – thanks so much. One missing link for me was logging into the database in SQL Server Management Studio. Use \.pipeMSSQL$MICROSOFT##SSEEsqlquery
    as the server name. It worked for me.

    • Nev
      August 31st, 2010 at 12:38

      Glad you posted this, helped me greatly

  37. Boris Gomiunik
    April 14th, 2010 at 17:58

    Thanks for the tip, Julie :)

  38. Mudit
    April 28th, 2010 at 13:48

    Thanks for this post! This helped me in shrinking ldf file.
    thanks!

  39. RAJ
    April 30th, 2010 at 10:16

    HI my SharePoint_Config_log.LDF file size is increased upto 30 gb and i used the same step and it show me same screen also after running command.But it did not shrink my SharePoint_Config_log.LDF file stil it is showing same size but in i got message that:
    “Cannot shrink log file 2 (SharePoint_Config_log) because all logical log files are in use.

    (1 row(s) affected)
    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    • Boris Gomiunik
      May 2nd, 2010 at 10:54

      @RAJ: It looks like your log file was in use while when you were trying to make this. Have you tried again at another time when the DB was not used?

  40. Afifi
    May 18th, 2010 at 00:57

    i’m using ms sqlserver 2008. Look like your post doesn’t work for sql server 2008. do you have other solution for that. Thank you.

  41. Eric
    May 19th, 2010 at 17:22

    Hello,

    This has helped me out greatly. Freed up about 20GB for me. This is actually the second time I have done it.

    At the start you say, ‘If you don’t perform a full farm backup the logs are not emptied’
    I run a full backup every night using STSADM.exe
    STSADM.exe -o backup -directory e:backupssharepoint -backupmethod full

    Even though I am doing a full backup the logs still get huge. Am I doing something wrong?

  42. CC
    July 29th, 2010 at 12:32

    This is all well and good if you can locate the sharepoint database in sql express management console, none of the recommendations to find it here have helped. any advice would be appreciated. I’m using SBS 2008. Thanks.

    • Boris Gomiunik
      August 8th, 2010 at 11:45

      @CC: Make sure, you’re opening the right database. If I’m not wrong SBS creates its own database for SharePoint.

  43. CIDM
    August 10th, 2010 at 23:16

    Excellent guide ! Thanks @Jose Angel for the permission issue.

    I had to use this connection string to get to Windows Internal Database

    \.pipeMSSQL$MICROSOFT##SSEEsqlquery

    Kudo @Boris Gomiunik

  44. Tan
    August 30th, 2010 at 10:35

    When I try and do the same for the WSS_content file I get:

    Msg 8985, Level 16, State 1, Line 1
    Could not locate file ‘WSS_Content_log’ for database ‘SharePoint_Config’ in sys.database_files. The file either does not exist, or was dropped.

    Any ideas?

  45. Nick
    September 1st, 2010 at 12:38

    First Class guide, thanks for posting this, it really helped me out.

  46. 01962
    September 27th, 2010 at 12:15

    Hi! Thank you to author for the info!
    Unfortunatelly I’ve met the same to LT problem. We use WSS3.0 on VM with limited disk space. According to guide above I installed SQL Server Management Studio and tried to connect to database and got a message “Cannot connect to ServerxxMICROSOFT##SSEE. “An error has occured while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections…………………. error:26 – Error Locating Server/Instance Specified)……………”
    As far as I understand we have WID with our WSS installed.
    Are there any idea how we can reach this database?
    Thenks in advance,
    Alex

    • April 30th, 2011 at 22:32

      I’m not easily impressed. . . but that’s impsrsenig me! :)

  47. Edward
    October 6th, 2010 at 17:31

    Should this make the logs folder disappear from the 12 hive?

    • Boris Gomiunik
      November 17th, 2010 at 21:05

      No, this does not affect the 12 hive. It affects the Content database logs.

  48. bas
    October 8th, 2010 at 15:04

    Hello,

    I Am running out of memory, therefore I thought to shrink the logfile.
    Everything went well untill I actualy schrank the database. the database decreased from 12 gig up to 13,5 gig. Now I’m realy running out of memory.

    Who can help me further.

    greatings bas

  49. Srdjan
    January 26th, 2011 at 16:40

    THANK YOU, THANK YOU, THANK YOU!!!! Just what I needed!

    It worked like a charm!

    One question: do we need the log backup for anything or can that thing be deleted? I do run the stsadm -o backup -directory C:SPbackup -backupmethod full command daily to back my SP site. Should that be enough to restore the SP server or do I need the log as well?

  50. Rob
    May 11th, 2011 at 14:52

    2 years and 7 months later and this post is still giving back.
    thanks
    worked perfectly.

  51. Jérôme DUMET
    May 26th, 2011 at 06:29

    Thank you very much for this article !

    I was experiencing log size problems with Sharepoint Services 3.0 SP2 and integrated SQL instance.

    NB : Here is the name of the instance to use with SQL Management Studio Express

    \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

    • JoeF
      July 12th, 2011 at 03:52

      Thanks…that’s what I needed on my SBS 2003 box.

      \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

  52. Ray
    July 1st, 2011 at 13:41

    I get the following message, when I try to backup the database;

    Msg 262, Level 14, State 1, Line 1
    BACKUP LOG permission denied in database ‘SharePoint_Config_a621cd13-15e7-4c4f-8f8a-fd1fadc25c26′.
    Msg 3013, Level 16, State 1, Line 1
    BACKUP LOG is terminating abnormally.

    • admin
      July 17th, 2011 at 09:42

      Perhaps you can check SQL permissions on the SharePoint_Config_a621cd13-15e7-4c4f-8f8a-fd1fadc25c26 database.