
Rudi Bruchez EI · www.pachadata.com · rudi@pachadata.com · +33 6 22 48 76 99
Consulting, audit, performance tuning, solutions, training
SQL Server OLTP and BI / NoSQL
Version of October 14, 2026 (4308dcaa) · https://www.pachadata.com/en/docs/howtos/database-maintenance/backup-ag/
Taking backups on an availability group
Schedule COPY_ONLY full backups and log backups on every replica of an availability group with Ola Hallengren, clean up with dbatools.
- 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
Contact
I have been an independent SQL Server consultant since 2006. I help when an application slows down, when a server costs too much in storage or licenses, or when a migration must not stop production: audit and diagnosis, query and index tuning, migrations, high availability, training. On site, or as a remote audit delivered in five working days.
rudi@pachadata.com · +33 6 22 48 76 99 · www.pachadata.com/en/contact/