I'm trying to understand the labyrinth that is the rules about AG backups.I've got Ola Hallengren's scripts installed on machines TST01/TST02. 02 is the preferred replica for backups. I have an AG with AdventureWorks in it and one database outside the AG - DBAutility.
I have the below in my SQL Agent job on TST01.
sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q “EXECUTE [dbo].[DatabaseBackup] @Databases = ‘User_Databases’, @CopyOnly = ‘Y’,@Directory = N’C:\MyDirectory\’, @BackupType = ‘FULL’, @Verify = ‘Y’, @CleanupTime = 168, @CheckSum = ‘Y’, @LogToTable = ‘Y'” -b
When I run the job on TST01 I get a backup of DBAUtility taken from TST01 and written to that machine. I get no backup of AdventureWorks. I'm taking this approach from a post from Brent Ozar.
I know Ola has other parameters for AG backups, but I couldn't seem to get that to work as expected either.