Skip to main content
Answer

Restore SQL database to Availability Group

  • April 2, 2024
  • 2 replies
  • 102 views

Forum|alt.badge.img+8

via Command Center it is not possible to restore a SQL-database “in place” to an availability group.

 

Does anybody have a workflow or Powershell-Script that can remove the database from the availability group before the restore … and back to the availability group after the restore?

 

Any help is very much appreciated.

 

Best regards.

 

Michael

Best answer by Albert Williams

Hello @Michael Seickert 

Thanks for the great question!
In regards to your question you can use the Pre/post script option if you build your own PowerShell script to run.

https://documentation.commvault.com/2023e/expert/pre_processes_and_post_processes_overview.html

The following commands are ones that can be used in that script: 

Remove Database:
https://learn.microsoft.com/en-us/powershell/module/sqlps/remove-sqlavailabilitydatabase?view=sqlserver-ps

Add Database:

https://learn.microsoft.com/en-us/powershell/module/sqlps/add-sqlavailabilitydatabase?view=sqlserver-ps

Kind regards
Albert Williams

2 replies

Forum|alt.badge.img+15

Hello @Michael Seickert 

Thanks for the great question!
In regards to your question you can use the Pre/post script option if you build your own PowerShell script to run.

https://documentation.commvault.com/2023e/expert/pre_processes_and_post_processes_overview.html

The following commands are ones that can be used in that script: 

Remove Database:
https://learn.microsoft.com/en-us/powershell/module/sqlps/remove-sqlavailabilitydatabase?view=sqlserver-ps

Add Database:

https://learn.microsoft.com/en-us/powershell/module/sqlps/add-sqlavailabilitydatabase?view=sqlserver-ps

Kind regards
Albert Williams


Forum|alt.badge.img+8

Hi Albert,

 

This was exactly, what I am was looking for. I will try this.

 

Thank you.

 

Best regards.

Michael