Solved

SQL Transaction logs

Posted on 2016-11-29
8
40 Views
Last Modified: 2016-11-29
Have 2008 R2 SQL server.  Had an issue over the weekend that caused the transaction log of one of the DB to fill up (DB is 6gb, Transaction log was 911gb!)  I configured maintenance plan thinking after the full backup, those logs would be shrunk but they haven't, my recovery mode is set to full,   I was thinking of setting to simple, shrink DB, and set back to full if that would clear the logs out.  But shouldn't maint. plan be doing that?
0
Comment
Question by:leadtheway
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905715
Is the maintenance plan backing the logs up as well? In full recovery you HAVE to back up the logs as well as the database.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905717
Oh, and don't shrink the database. Back the logs up and shrink the logs
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905835
yes theres a separate job for backing up the logs, but its not cleaning them,  how would I shrink the transaction log DB, ?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 41905862
Something like this:

BACKUP LOG MyDB TO DISK = N'X:\Backup\MyDB_log.bak'
GO
DBCC SHRINKFILE('MyDB_Log', 1)
GO

Open in new window

0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905893
ok when i look at the datapath for the DB in question i see 2 files

DBName= primary datafile
DBName_1=Transaction Log file, so in your scenario by doing below


BACKUP LOG DBNAME TO DISK = N'X:\Backup\DBName_log.bak'
GO
DBCC SHRINKFILE('DBName_Log', 1)
GO


That would just backup the transaction log file and then shrink it right, i don't have to specify the DBNAME_1 listed above?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 41905900
My code example is telling SQL to back up the log for the database named MyDB so you give it the name of the database. SQL will get the log file name from the database properties. No you don't specify the name of the log file until you tell ShrinkFile which file you want shrinking.
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41905908
so in this case for the dbcc Shrinkfile i would specify the name of the log file in the datapath (dbname_1)
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41906279
i ended up doing a combination of putting in simple recovery mode and then doing shrinkfile, cleared the neccessary space
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question