I’ve been lapping up some sunshine in the garden but the weather is now changing again, so it’s back indoors and time to post something. From some recent work I was doing, here are some scripts for DAG failover to DR site and switchback again. There are specific assumptions here; firstly, I was working with two mailbox servers in my main site and a single mailbox server in the DR site. Secondly, I had a single DAG. Thirdly, I was using the same CAS Array for both sites – that is not necessarily always going to be the case, but this was just a DR site, so was appropriate for me. Finally, I was blocking database activation in the DR site. You can easily modify the scripts according to your circumstances and need to modify some of the tags anyway.
< MAIN_SITE>
< DR_SITE>
< DAGNAME>
< DR_MBX_SERVER>
< CASARRAY>
In my example there are 15 mailbox databases named DB01-DB15.
#### TERMINATE FAILED DATACENTER
#### if mailbox server(s) in
POWER OFF
### or
Stop-DatabaseAvailabilityGroup
#### if AD is available in
Stop-DatabaseAvailabilityGroup
#### check that the mailbox servers have stopped in
Get-DatabaseAvailabilityGroup | select Name,*server*
#### run in
Stop-DatabaseavailabilityGroup
#### ACTIVATE DR SITE
#### run in
stop-service ClusSvc
Restore-DatabaseAvailabilityGroup
(repeat above if necessary)
1..9 | ForEach-Object {Move-ActiveMailboxDatabase DB0"$_" -ActivateOnServer
Set-clientaccessarray
#### SWITCHBACK
#### run in
Start-DatabaseAvailabilityGroup
(repeat above if necessary)
Set-clientaccessarray
#### check that mailbox servers in
Get-DatabaseAvailabilityGroup | select Name,*server*
#### move databases back to
origlocation$=get-location; set-location exscripts$; .\RedistributeActiveDatabases.ps1 -
(repeat above if necessary)
#### if appropriate, block
Set-MailboxServer