SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Logshipping Backup Files Management

By Vaibhav Mehta,


The problem occurs very frequent in the environments where Log Shipping is configured. Many times log files on disk get larger due to large SQL processes eating extra disk space This makes DBA to identify the log files which are restored on destination server and are no more required on source server , but are still occupying unnecessary space on source server disk. With this the database that are using same disk in which logs are saved can go in suspect mode If it would not be taken care in time than end users\work would be affected very badly . So to remove log files ,DBA has to first identify the primary and all the secondary servers involved in log shipping. Secondly, which all logs are restored on secondary servers , helping to identify which logs are no more required. So to resolve issues well in time, the DBA will use the automated script to do the job well in short time. This is very typical for any DBA to handle this type of situation in minimum time.


There are two separate scripts for primary and secondary log shipping server. Execute the script accordingly or schedule it as job.

 Change the value of "@DriveSpace" parameter to the Percent % free space you want on drive. At present it is set to 20. Which will leave 20% free space on drive.

Total article views: 645 | Views in the last 30 days: 1
Related Articles

Show Database and Log sizes, free space and location

This script helps to identify which database/log takes most of the disk space and how much is free.


Identify Servers and the Databases Mounted in SharePoint

Identify the Database Server which is used to mount the database in Sharepoint 2010


Check Used Table Space for User Defined Tables

Query the System Tables to find the space usage, which helps Database Administrators identify the Ta...


How to get space used in SQL Server 2000

How to get space used in SQL Server 2000 (script)


Identify tempdb usage

Identifies SQL and or Jobs that are using tempdb space.