Thor Logo dbatools

Mirroring

Add-DbaDbMirrorMonitor

Chrissy LeMaire (@cl), netnerds.net

Add-DbaDbMirrorMonitor View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on the server instance. Description Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on the server instance. Basically executes sp_dbmmonitoraddmonitoring. Syntax Add-DbaDbMirrorMonitor [-SqlInstance] <DbaInstanceParameter[]> [[-SqlCredential] <PSCredential>] [-EnableException] [-WhatIf] [-Confirm] [<CommonParameters>] Examples Example: 1 PS C:\> Add-DbaDbMirrorMonitor -SqlInstance sql2008, sql2012 Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on sql2008 and sql2012.

Read more

Get-DbaDbMirror

Chrissy LeMaire (@cl), netnerds.net

Get-DbaDbMirror View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Retrieves database mirroring configuration and status for mirrored databases and their witness servers Description This command collects detailed mirroring information from databases configured with SQL Server Database Mirroring, including partner servers, witness servers, safety levels, and synchronization status. It queries both the database properties and the sys.database_mirroring_witnesses system view to provide complete mirroring topology details. Use this when you need to audit your mirroring setup, troubleshoot mirroring issues, or verify mirroring configuration across multiple instances without manually checking each database’s mirroring properties in SSMS.

Read more

Get-DbaDbMirrorMonitor

Chrissy LeMaire (@cl), netnerds.net

Get-DbaDbMirrorMonitor View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Retrieves database mirroring performance metrics and monitoring history from SQL Server instances Description Retrieves detailed database mirroring performance statistics from the msdb monitoring tables, helping you track mirroring health and identify performance bottlenecks. This function executes sp_dbmmonitorresults to pull metrics like log generation rates, send rates, transaction delays, and recovery progress from both principal and mirror databases. Use this when troubleshooting mirroring performance issues, monitoring replication lag, or generating compliance reports for high availability configurations.

Read more

Invoke-DbaDbMirrorFailover

Chrissy LeMaire (@cl), netnerds.net

Invoke-DbaDbMirrorFailover View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Fails over database mirroring configurations to the mirror server Description Performs a database mirroring failover by switching roles between the primary and mirror servers. For synchronous mirroring, sets safety level to Full and executes a clean failover without data loss. For asynchronous mirroring or emergency situations, use -Force to allow a forced failover that may result in data loss.

Read more

Invoke-DbaDbMirroring

Chrissy LeMaire (@cl), netnerds.net

Invoke-DbaDbMirroring View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Creates and configures database mirroring between SQL Server instances with full validation and setup Description Creates database mirroring configurations between SQL Server instances, handling the complete end-to-end setup process that would normally require dozens of manual T-SQL commands and careful validation steps. This function eliminates the complexity and potential errors involved in manually configuring database mirroring partnerships. The function performs comprehensive validation before setup and handles all the technical requirements:

Read more

Remove-DbaDbMirror

Chrissy LeMaire (@cl), netnerds.net

Remove-DbaDbMirror View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Breaks database mirroring partnerships and stops mirroring sessions Description Terminates database mirroring sessions by breaking the partnership between principal and mirror databases. This command stops the mirroring relationship completely, which is useful when decommissioning mirrors, performing maintenance that requires breaking the partnership, or during disaster recovery scenarios where you need to bring a database online independently. Important: This function only breaks the mirroring partnership - it does not automatically recover databases that are left in a “Restoring” state.

Read more

Remove-DbaDbMirrorMonitor

Chrissy LeMaire (@cl), netnerds.net

Remove-DbaDbMirrorMonitor View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Stops and deletes the mirroring monitor job for all the databases on the server instance. Description Stops and deletes the mirroring monitor job for all the databases on the server instance. Basically executes sp_dbmmonitordropmonitoring. Syntax Remove-DbaDbMirrorMonitor [-SqlInstance] <DbaInstanceParameter[]> [[-SqlCredential] <PSCredential>] [-EnableException] [-WhatIf] [-Confirm] [<CommonParameters>] Examples Example: 1 PS C:\> Remove-DbaDbMirrorMonitor -SqlInstance sql2008, sql2012 Stops and deletes the mirroring monitor job for all the databases on sql2008 and sql2012.

Read more

Repair-DbaDbMirror

Chrissy LeMaire (@cl), netnerds.net

Repair-DbaDbMirror View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Repairs suspended database mirroring sessions by restarting endpoints and resuming mirroring Description Restores database mirroring functionality when mirroring sessions become suspended due to network connectivity issues, log space problems, or other transient failures. This function performs the standard troubleshooting steps that DBAs typically execute manually: stops and restarts the database mirroring endpoints on the SQL Server instance, then resumes the mirroring session between the principal and mirror databases.

Read more

Set-DbaDbMirror

Chrissy LeMaire (@cl), netnerds.net

Set-DbaDbMirror View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Configures database mirroring partner, witness, safety level, and operational state settings. Description Modifies database mirroring configuration by setting the partner server, witness server, safety level, or changing the mirror state. This function lets you reconfigure existing mirrored databases without manually writing ALTER DATABASE statements. Use it to add or change witness servers for automatic failover, adjust safety levels between synchronous and asynchronous modes, or control mirror states like suspend, resume, and failover operations.

Read more