Taking backups on an availability group

Taking backups on an availability group
  1. Download and install Ola Hallengren’s procedure.
  2. Schedule COPY_ONLY full backups on each replica. This assumes the availability group is configured to prefer backups on the secondary replica. To check that, use this query and look at the automated_backup_preference column.
  3. Schedule log backups on each replica. Ola Hallengren’s procedure automatically runs the backup on the preferred replica. You can use the example calls on my GitHub.
  4. To delete the old backups, on a schedule if you want, you can use dbatools and this command:
Remove-DbaBackup -Path '\\backup-server\repo$\CLUSTER-SQL-AG\MyDatabase\' -BackupFileExtension bak -RetentionPeriod 48h