SQL Server – Sync Server Objects with Multiple Availability Groups

availability-groupsdbatoolssql serversql-server-2016

Lets imagine that i have two servers/nodes with TWO availability groups Group01 and Group02. I will need to ensure that the server objects are all the time recreated over the secondary replica.

If i have the Group01 in one node as primary, and the Group02 in the other node as primary, how will the sync of server objects be processed?

I was thinking of using dbatools with one command line only:

Start-DbaMigration -Source $PrimaryInstance `
                   -Destination $SecondaryInstance ` 
                   -Exclude Databases

What am I missing here?

Best Answer

The server object are at the server level e.g. logins, jobs, etc. So you can just use Sync-DbaAvailabilityGroup

Syncs depdendent objects for availability groups. Such objects include:

SpConfigure
CustomErrors
Credentials
DatabaseMail
LinkedServers
Logins
LoginPermissions
SystemTriggers
DatabaseOwner
AgentCategory
AgentOperator
AgentAlert
AgentProxy
AgentSchedule
AgentJob

What you are using is a much bigger umbrella that folks use for migration from one server to another.