Sql-server – Restoring a Database in an Availability Group

availability-groupshigh-availabilitysql server

I located an extremely helpful process outlined in the thread below, but needed some clarification. This may be a silly question, but I'm a bit new to Availability Groups. In the steps outlined in the thread's answer, is it true that after restoring, you only have to add the newly restored database into the secondary? Will it appear back into the primary automatically? Thank you for any assistance!

Restoring a SQL Server 2012 database in high availability

Best Answer

Yes, you need to populate databases on secondary nodes in an availability group yourself, they do not appear "automatically". The full documentation is found on MSDN, with multiple ways to execute. The short version is:

  • Your primary database needs to be in FULL recovery mode.
  • You must restore the database in NORECOVERY mode on the secondary node. Logs must be applied so that the secondary database is as close to the current transaction state of the primary as possible.
  • Once you have done this, you need to join the secondary database to the availability group: ALTER DATABASE [foo] SET HADR AVAILABILITY GROUP = [bar];