Sql-server – Are there differences between which AlwaysOn AG server (Primary or Secondary Replica) I store the backups and retention maintenance plans on

backupmaintenancemaintenance-planssql serversql-server-2016

I have an AlwaysOn AG system in place between two servers. Server A hosts the primary replica, Server B hosts the secondary replica.

Are there any differences if my Full & Transaction Log Backups are stored on Server A vs Server B?

Are there any differences if my backup retention maintenance plan and job is ran on Server A vs Server B (regardless of where the backups live)?

My current setup is Server A has a SQL Agent job that runs a maintenance plan on Server B to back up my databases to Server B. In that same job on Server A there's a subsequent step that runs a maintenance plan on Server A that cleans up old backups from Server B.

Best Answer

You should not have your backup files on the SQL server as you would lose those backup if ever there is an issue with the SQL server.

Best practice would be to store your backup outside of the SQL Server (on a shared folder for example) that can be accessed by both node of the AG.

As the primary node can switch from one or the other node, you should code your backup job to only backup on the "prefered" node (which will be set in your AG).

I would also recommand you to use something else then SQL Maintenance jobs (have a look at : https://ola.hallengren.com/)

Usually, the backup are running on the primary node as you cannot do diff backup on a secondary node and as the secondary node data files could be behind the prod one (even in synchronous mode).

For the cleanup job, you could simply use a powershell script that will delete files from that shared folder.