SQL Server – Does Log Shipping Truncate Transaction Log?

backuplog-shippingsql servertransaction-log

I have setup log shipping on a database in Microsoft SQL Server 2012.

I was having issues with my secondary server and I found that this was probably due to a scheduled backup job messing up the log file consistency.

The solution was to set the job to do a copy_only backup however, now I am curious as to whether the log shipping will take care of the transaction log size, or will it just grow indefinitely?

Question: Will log shipping take care of truncating the log file?

Best Answer

The LSBackup job in a log shipping configuration performs a transaction log backup, so this will help maintain your log file size the same as a normal log backup job does.

Note that this will not truncate the file (reclaim space), it simply marks the portions of the log that have been backed up as available for re-use and this helps prevent log file growth by reusing existing space in the file. For performance reason, you don't want to be shrinking and regrowing your transaction log file constantly.

Typically if you're using log shipping there is no need to run another copy-only log backup job, you're better off simply copying the log backups that LSBackup creates into a suitable storage location. You will also run into problems if you're running LSBackup and a non-copy only log backup job as the restore chain will be broken on the secondary, as you've found.