Sometimes it bother me how long it takes to throw a single switch which resolves a problem. This was one of those times.
Here’s the scenario. An availability group is set up and you want to log ship one of the databases to a designated DR server so you have both HA and DR at your disposal. Everything sets up just as it should, but when you run the backup no file appears in your backup directory. What’s going on?
For a while I went around in circles trying to second guess my log shipping setup. Then I made a second database, successfully configured log shipping, but the moment I added it to the availability group it began exhibiting the same behaviour. There are no errors in the logs, the backup job says it’s successful, but when you go into the error logs all you find is it is deleting old backups that have fallen out of retention. No backup is made. The databases last backup date does not change.
I went so far as reading the entire support notes on books online around availability groups trying to find anything to suggest this couldn’t be done. Then I repeated my experiments to confirm that log shipping worked fine outside the availability group, but failed when it was added. Finally I came to the conclusion that should have been obvious an hour earlier. The problem must be something to do with the group set up. Once I got there the likely culprit was clear – the availability group was trying to enforce a backup being taken off the secondary replica, and the log shipping job didn’t like that. It seems to check if it can take a local backup, see that it can’t and so skip straight to the historic backup purge.
Here’s how to correct it.
- In management studio expand Always On High Availability and then Availability Groups.
- Right click on your chosen group and choose properties.
- In the left pane select backup preferences.
- Select ‘Primary’ as your backup source. Click Okay.
Now run your log shipping log backup job and everything should perform as expected.