I want to backup all the databases in an availability group except one. Using the @AvailabilityGroups option in Ola's Maintenance Solution scripts, can a single database in an Availability Group be excluded from a backup?
Select databases. The keywords SYSTEM_DATABASES, USER_DATABASES, ALL_DATABASES, and AVAILABILITY_GROUP_DATABASES are supported. The hyphen character (-) is used to exclude databases, and the percent character (%) is used for wildcard selection. All of these operations can be combined by using the comma (,).
So as you list the databases to back up, it will look like this:
All databases like
Db will be excluded from the backup while the rest of the databases in the availability group will be backed up. Change that Db to be the one you want to not backup and adjust the % signs as applicable to your database.
For excluding a database from the backup script in Ola Hellengren's solution, you will need to add it like the below:
AVAILABILITY_GROUP_DATABASES, -UserDb : All databases in AG , except Db1
The above will backup all databases in AG except UserDb. For more information please go through the Databases parameter in the below link