Creating AlwaysOn Availability Group With Scripts
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.