Database mirroring and transaction log files

When a partner 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. You can store the transaction log files and the database file in the same directory. However, this directory should not contain other files because it can cause delays in starting the database.

The server that takes on the primary server role must have a transaction log with the same starting offset as the current transaction log on the mirror server, as well as any subsequent transaction log files up to the current transaction log file for the primary server.

Once a server takes on the mirror server role, 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 about 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 a different method than truncating the transaction log (such as a scheduled event that uses xp_cmdshell to delete files that are more than one week old).