olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.89k stars 748 forks source link

logic to filter databases in maintenance procedures #612

Open CG078 opened 2 years ago

CG078 commented 2 years ago

Hi there,

Would it be possible to add a feature to help filter out databases that are not in an online state. We would also like to filter out databases that are in an availability group which is in the secondary role.

We are running in to issues when we run our indexoptimize, databasebackup and databaseintegritycheck on our servers. We regularly have databases that are either offline or are in restoring states. These can happen when processes are running. This is overlapping when maintenance is running.

We also have issues when we want to run maintenance activities on our secondary replicas. We do have some user databases that are not part of an availability group. We use a single job on all servers. It would be nice if the maintenance procedures could have a parameter to ignore secondary replica databases.

This way we can deploy a single job and we won't have to programmatically work out servers we can perform maintenance on.

Thank you. Craig.

griffitmatt commented 2 years ago

Hi There is a parameter AvailabilityGroupReplicas for integrity checks. Could you try using this option?

-AvailabilityGroupReplicas

Value | Description ALL | Checks all replicas PRIMARY | Checks the primary replica only SECONDARY | Checks all secondary replicas

Also Index optimize should skip over offline/restoring databases?

How have you configured your backups on the availability group?

Are you planning to do one scheduled job to perform all these tasks?