Ola backups happening on both Primary and Secondary AG I configured Ola's scripts on a staging AG configuration to test out the logic. When I checked the backup folder today after a week, I see that the backups are happening both on the primary replica and copy_only backups on the secondary replica. 

It is my understanding that the backups are supposed to happen on the secondary replica - And I have configured the AG to "Prefer secondary". I don't want the backups happening on both primary and secondary on this 2 node AG. What can be done for this to work? Please advise.
Validate that:


Backup Priority is higher on the Secondary instances
None of the secondaries are excluded
You are looking at Synchronized (in the AG) databases
You do not have OverrideBackupPreference set in the Ola cmd line


Check your DBName. If I call sys.fn_hadr_backup_is_preferred_replica with a @DatabaseName that does not exist on the instance it returns a 1. If you have validated all this and it still returns a 1 on both replicas then the issue is not the OLA scripts, the issue is your AG configuration.



Community Wiki answer created from comments by IanG