SQL 2005 and LDF files. Are the following command acceptable and sufficient?


i inherited sql 2005 server has database sbo-common in full recovery model.

sbo-common, d:\sql data\sbo-common.mdf, initial size 596 mb
sbo-common_log, d:\sql data\sbo-common_log.ldf, initial size 30000 mb

as of now,

sbo-common.mdf 609kb
sbo-common_log.ldf 29322533kb

if schedule following commands every night before tape backup runs:

---------------------------------------------------

use [sbo-common]
go
backup database [sbo-common] disk = 'f:\sql backup\sbo-common.bak'
go
backup log [sbo-common] disk = 'f:\sql backup\sbo-common_log.bak'
go
dbcc shrinkfile ('sbo-common_log',emptyfile)
go

------------------------------------------------------------------------

would above acceptable , sufficient?  want sbo-common_log.bak file shrink.

what if did following?

----------------------------------------------------

use [sbo-common]
go
dbcc shrinkfile ('sbo-common_log',emptyfile)
go
backup database [sbo-common] disk = 'f:\sql backup\sbo-common.bak'
go
backup log [sbo-common] disk = 'f:\sql backup\sbo-common_log.bak'
go

------------------------------------------------

how affect ability restore db tape backup if happens? 

while first solution you're after (shrinking log after taking backups), second solution won't have effect, you're trying shrink log before it's been backed up.  this means there less available room perform shrink.

note emptyfile has no effect on log file - used remove data 1 data file in filegroup data file in filegroup.

i can understand you'd want shrink 30gb log file, shrinking files nightly not recommended practice.  the log file need grow again next day, , while growing, users have wait (it doesn't take long grow couple of hundred mb, still).  it can result in multiple virtual log files, can decrease performance significantly.

i'm going on assumption log has grown 30 gb because in full recovery model , haven't been taking log backups now.  what suggest perform full , log backup, , perform shrink once.  shrink file down to, 150 mb (a size 600 mb database).  then, run full , log backups each night , monitor growth of file.  

what you'll see log file size auto-grow size needs @ accommodate entire day's worth of transactions.  if rebuild indexes/tables in database, you'd looking @ 600 mb worth of activity in log file.  after few weeks, should see log file size stabilise, , without need shrink it.  shrinking should done respond abnormal growth.


SQL Server  >  SQL Server Database Engine



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607