With the release of version 7.4 in August, SQL Safe added AlwaysOn Availability Group support by taking into account the preferred replica when backing up availability replicas. The preferred replica setting is only checked when backups are done through a SQL Safe Backup Policy. When the Policy backup runs, SQL Safe will first check if the database is the preferred replica by running the Microsoft function sys.fn_hadr_backup_is_preferred_replica. If it is the preferred replica, the database will be backed up. If not, the backup will be skipped. This allows you to add all of your replicas to a policy knowing that only one backup will be taken, rather than duplicate backups from each replica.
Note: An ad-hoc backup done outside of a Backup Policy will NOT take the preferred replica setting into account. This allows you to backup your non-preferred replicas if the need arises.
Backing Up Availability Group Replicas
Before backing up your availability group replicas using a SQL Safe Backup Policy, you must first register each Availability Group instance in the SQL Safe Management Console. Then, add all of your replicas on the Membership page of the Backup Policy Wizard, as shown below:
On the Locations page of the wizard, you can specify the location where the backups will be written. We recommend using a UNC path for the backup location, so that when you need to restore, all Availability Group instances will be able to access the backup files, regardless of which instance did the backup. If you instead specify a local drive here, you may need to provide a network path to these files during restore, if the restore is being done on another instance.
Note: When the Backup Policy is scheduled to run, the backup will only be taken on the preferred replica, and the backup will be skipped on the other non-preferred replicas.
Restoring Availability Replicas
The Restore Wizard can be used to identify all backups needed for the restore chain, even when the backups were taken from different availability replicas.
Below is a screenshot showing a Backup Policy where the backups were taken from two different replicas: the Full and first Log backups from SS-ALWYSN201203, and the second Log backup from SS-ALWYSN201201. The backups were written to a local directory, C:\Backup.
When restoring these backups, the Backup Sets section of the Restore Wizard will assemble all of the backups needed for the restore:
In this case, the restore is being done to instance SS-ALWYSN201202. The Backup Agent on SS-ALWYSN201202 cannot access the files using the paths specified during the backup, since they are local paths on SS-ALWYSN201201 and SS-ALWYSN201203. Because of this, the wizard will prompt for a different path to the files:
A Backup File Locations dialog will open showing the original path used during backup:
A UNC path to this file will need to be provided, so that the Backup Agent can access it remotely. You can browse for the network location, or type it directory into the Location field:
If the Backup Agent doing the restore does not have permission to access the file, the wizard will prompt for credentials:
This will be repeated for each backup file that cannot be accessed by the Backup Agent doing the restore. In this case, a new path had to be provided for all three files being restored, since all three were backed up on a server other than the restore server.
Note: If these backups had been written to a UNC path originally, it would not be necessary to provide alternate paths.
Below is a screenshot showing the successful restore, using the new file paths provided: