Sql-server – Replacing Database in High Availability Group Enviroment

availability-groupssql serversql-server-2012

Looking for some advice regarding replacing a database within a SQL 2012 High Availability Group environment setup as synchronous with auto failover. A little bit of background on the reason for this.

Every couple of months we get a MDB database from a supplier which then need to be imported into a SQL database. This is done by 2 step job that first truncates current database and then recreates and then a SSIS package is run to fill the database.

As I'm trying to automate the full process any suggestions and advice would be greatly appreciated.

I know I need to first remove the database from the availability group and then apply the changes, but was interested to find out what the best approach with the secondary is and best practice. Im guessing I can either delete the database from the secondary and then add it back into the Availability group or is it better to take a backup of primary and restore over secondary before adding back to HA

Best Answer

With SQL Server 2012, there is only one way to synchronize a database when it is added to an availability group--backup and restore. So you will need to drop the database from the secondary and restore the primary's backup (or restore with overwrite) when adding the database to the availability group.

With SQL Server 2016 and later, automatic seeding is available for initial synchronization, so the backup/restore process can be skipped if seeding is enabled on the AG.