HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Does MSSQL log shipping automatically remove the backup files from both servers?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thelogserversautomaticallymssqlbothremovefilesdoesshipping

Problem

Does Microsoft SQL Server's log shipping feature remove the backup files automatically? I am concerned that the secondary server's hard drive will reach capacity unless the previously restored files get removed.

I have not been able to find a reliable answer to this anywhere.

Solution

Log Shipping utilises an executable called SqlLogShip.exe. As per the documentation, when it runs as part of the LSBackup job, it removes old backup files outside the defined retention period on the primary:


The backup operation creates the log backup in the backup directory.
The sqllogship application then cleans out any old backup files, based
on the file retention period. Next, the application logs history for
the backup operation on the primary server and the monitor server.
Finally, the application runs sp_cleanup_log_shipping_history, which
cleans out old history information, based on the retention period.

When it runs as part of the LSRestore job, it removes old backup files outside the defined retention period on the secondary server:


Any backup files in the destination directory that were created after
the most recent restore point are restored to the secondary database,
or databases. The sqllogship application then cleans out any old
backup files, based on the file retention period. Next, the
application logs history for the restore operation on the secondary
server and the monitor server. Finally, the application runs
sp_cleanup_log_shipping_history, which cleans out old history
information, based on the retention period.

Provided your retention periods are set and SqlLogShip.exe is executing correctly, it should maintain the log files on both the primary and secondary locations.

Context

StackExchange Database Administrators Q#226741, answer score: 3

Revisions (0)

No revisions yet.