Database mirroring and transaction log files

When an operational server starts, it examines all the transaction log files in the same directory as the current transaction log file and determines which ones need to be applied. The database server then applies the operations in these transaction logs to the database before determining whether to act as the primary or mirror server.

Once a server takes on the role of mirror, it starts receiving transaction log pages from the primary server. When a transaction log rename occurs on the primary, the rename is also performed on the mirror. The mirror then writes new transaction log pages to a new file with the name specified for the transaction log.

Transaction log files can be deleted periodically on the primary. Each time a transaction log file is renamed, the mirror is notified as to which transaction log file is the oldest surviving file on the primary. Any transaction log files older than this are deleted on the mirror.

Because a mirror server may not be available when a backup is performed against the primary server that requests a transaction log truncation, deletion of transaction logs on the primary must be performed using different method than truncating the transaction log (such as a scheduled event that uses xp_cmdshell to delete files more than one week old).