Taking backups on an availability group
Taking backups on an availability group
- Download and install Ola Hallengren’s procedure.
- Schedule
COPY_ONLYfull 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 theautomated_backup_preferencecolumn. - 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.
- 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