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.


2 Answers 2


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


Use the below to see if the current node is the correct node and only run the backup if so:

SELECT sys.fn_hadr_backup_is_preferred_replica (@DatabaseName)
  • I created a backup schedule with the maintenance plans and they are happening only on the secondary replica as expected. I am guessing something else needs to be changed in the ola script for it to properly work Commented May 25, 2017 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.