There is a function that Microsoft provides for AlwaysOn to determine whether a database is the preferred replica. LiteSpeed supports AlwaysOn if you wanted to move away from custom scripts and start using Backup Templates or Maintenance Plans.
There is no LiteSpeed equivalent to the native functionality. We use the Microsoft SQL Server supplied function. We only support AlwaysOn via Backup Templates or Maintenance Plans. LiteSpeed uses a T-SQL script with native calls. Unfortunately there is no function in LiteSpeed to do the replica test.
This is the function we leverage: sys.fn_hadr_backup_is_preferred_replica
http://msdn.microsoft.com/en-us/library/hh213235.aspx
In regards to AlwaysOn Availability Groups and backups:
The backups need to be scheduled to run on each replica, if there is a chance that the replica would be needed for backups. For example, if you had 3 replicas: one primary (P1) and two secondaries (S2 and S3) and you set up SQL Server to preference backups in this order: (S2, P1, S3), you need to make sure the backup jobs are created and scheduled on each of those instances. In the script, you would use the Microsoft supplied function to test whether the database is the preferred replica for backup. If it is, run the backup. Otherwise, exit the script doing nothing. That’s effectively what Litespeed does when using Backup Templates or Maintenance Plans.
But we do provide additional options:
• Backup up preferred replica (the preferred is backed up)
• Always back up the primary replica (always back up the primary to avoid added licensing costs for SQL Server)
• Back up the primary and all secondaries (good when you have 2 data centers in different geographic regions with different DBA teams who need local access to backups)
• Back up none (avoids backing up any database in an Availability Group – presumably because they are being controlled via other scripts)