Configuration

Sync-sqmBackupExcludeTable

Propagates the sqmBackupExclude exclusion table from the primary instance to all secondary replicas of an Availability Group — ensures consistent backup exclusion across the AG after changes made via Show-sqmBackupExcludeForm.

Module: sqmSQLTool
Requires: dbatools
ShouldProcess: Yes (Medium)
Output: PSCustomObject[]

Execution Flow

START 1. Invoke-DbaQuery → read sqmBackupExclude from primary 2. Get-DbaAvailabilityGroup → resolve secondary replicas -IncludeSystemDatabases? include system DBs in sync foreach secondary replica ShouldProcess: sync to replica? skip (WhatIf) Invoke-DbaQuery → TRUNCATE sqmBackupExclude on secondary -SkipAlwaysOnPropagation? skip AG replicas INSERT excluded databases into secondary Return PSCustomObject[] (one entry per secondary) DONE
Typically called after Show-sqmBackupExcludeForm saves changes on the primary, or scheduled alongside Sync-sqmLoginsToAlwaysOn. Use -SkipAlwaysOnPropagation when the table is already replicated via AG (Distributed Transaction or manual sync). -IncludeSystemDatabases adds system databases (master, model, msdb, tempdb) to the exclusion sync.

Parameters

ParameterTypeRequiredDescription
-SqlInstanceStringOptionalPrimary instance. Default: $env:COMPUTERNAME.
-SqlCredentialPSCredentialOptionalSQL authentication credential.
-IncludeSystemDatabasesSwitchOptionalAlso sync system database exclusions (master, model, msdb, tempdb).
-SkipAlwaysOnPropagationSwitchOptionalSkip AG secondary replicas (use when table is replicated via other means).
-EnableExceptionSwitchOptionalThrow terminating errors instead of logging warnings.
-WhatIf / -ConfirmSwitchOptionalStandard ShouldProcess support.

Return Value

Returns a PSCustomObject[] — one entry per secondary replica — with: Primary, Secondary, RowsSynced, Status, Message.

Examples

Example 1 — Sync exclusion table to all AG secondaries

Sync-sqmBackupExcludeTable -SqlInstance "SQL01"

Example 2 — Preview without changes

Sync-sqmBackupExcludeTable -SqlInstance "SQL01" -WhatIf

Example 3 — Include system databases in sync

Sync-sqmBackupExcludeTable -SqlInstance "SQL01" -IncludeSystemDatabases