One day, your Availability Group cluster can get into a critical state in a way that forces your team to create the Availability Group from scratch.
The following scripts can save you’re A$$ and for sure, save a lot of time.
Always be ready!
All you need to do is to fill in the appropriate places your objects names, IP, backup path etc. (Use the checklist – 00)
Notice that the scripts create the Availability Group and not the Windows Cluster. That needs to be already set up and must include all the Cluster Resources based on your environment (quorum, file share, network, servers). It’s also a good idea to first take a backup of the cluster configuration, using the windows backup feature.
The following steps and AlwaysOnScripts will create the Availability Group from scratch:
Create Mirroring Endpoint.
Restore your database\s to the Primary from backup file.
Create The Availability Groups And a Listener on the Primary.
Join The secondary replica to the Availability Groups.
Take Full Backup for your Primary database\s.
Restore the FULL backup in the Secondary With NORECOVERY mode.
From the Primary, Take Log Backup for your database\s
Restore The Log Backups in the Secondary With NORECOVERY mode.
Join The Database\s in the Secondary To The Availability Group.
Now we’ll all be AlwaysOn.
The download link for the script appears to be broken.
But no worries, it's available in our Madeira Toolbox repository on GitHub:
https://github.com/MadeiraData/MadeiraToolbox/blob/master/High%20Availability%20Solutions/Availability%20Group%20Setup%20Script.sql