GithubHelp home page GithubHelp logo

Log backups are not working for availability groups with backup preference set to 'Prefer Secondary' about sql-server-maintenance-solution HOT 5 OPEN

mitesh-p avatar mitesh-p commented on July 1, 2024
Log backups are not working for availability groups with backup preference set to 'Prefer Secondary'

from sql-server-maintenance-solution.

Comments (5)

griffitmatt avatar griffitmatt commented on July 1, 2024

" The full and diff backups are running on the primary but those backups are working only 'LOG' backups are not working."

Hi Mitesh checking are you running the backup on the primary or secondary replica?

from sql-server-maintenance-solution.

mitesh-p avatar mitesh-p commented on July 1, 2024

from sql-server-maintenance-solution.

griffitmatt avatar griffitmatt commented on July 1, 2024

refer to https://ola.hallengren.com/frequently-asked-questions.html

How should I configure DatabaseBackup to back up an Availability Group?
First you need to decide where you want the backups to be performed; on the primary replica or on the secondary replica. SQL Server has an option called backup preference that you can set on the availability group. By default it is set to Prefer Secondary, but you can change it to Primary if you prefer that.

Not all backup types are supported on the secondary replica. Here are the backup types that are supported:

Copy-only full backups
Log backups (non copy-only)
DatabaseBackup will perform these types of backups on the preferred backup replica. It is using the function sys.fn_hadr_backup_is_preferred_replica to determine if the current replica is the preferred replica.

Full backups (non copy-only) and differential backups are only supported on the primary replica. DatabaseBackup will always perform these types of backups on the primary replica.

Here are some different backup strategies that you can use:
Perform all the backups on the primary replica. With this strategy it works just like with any database. You can perform full (non copy-only), differential, and log backups. All you need to do is to set the backup preference to Primary for the availability group.

Perform all the backups on the secondary replica. With this strategy you can only perform copy-only full, and log backups (non copy-only). You need to check that the backup preference is set to Prefer Secondary for the availability group. You also need to add @copyonly = 'Y' to the full backup jobs, and disable the differential backup jobs.

Perform full (non copy-only) and differential backups on the primary replica, and log backups on the secondary replica. You need to check that the backup preference is set to Prefer Secondary for the availability group. You don't need to add any additional parameters to the full, differential, or log backup jobs.
The jobs should be configured identically and be enabled and scheduled on all the replicas.

from sql-server-maintenance-solution.

Boran avatar Boran commented on July 1, 2024

I have a similar experience.
using SQL 2019, standard edition, which only allows backups to be done on the primary.

With standard edition:
ALTER AVAILABILITY GROUP FooAG SET (AUTOMATED_BACKUP_PREFERENCE = PRIMARY)
"The specified command is invalid because the Always On Availability Groups backup preference feature is not supported by this edition of SQL Server."

  • full and different backups run fine (on the primary)
  • LOG: AGs are ignored, except the first (which contains the listener). There are three AGs.

Step: DatabaseBackup - USER_DATABASES - LOG
EXECUTE [dbo].[DatabaseBackup]
@databases = 'USER_DATABASES',
@Directory = NULL,
@BackupType = 'LOG',
@verify = 'Y',
@Cleanuptime = NULL,
@Checksum = 'Y',
@LogToTable = 'Y'

Also tried
@AvailabilityGroups='ALL_AVAILABILITY_GROUPS'

In the commandLog table I only ever see just one AG.

The following runs one for each AG on the primary:
select sys.fn_hadr_backup_is_preferred_replica ( 'fooAG' )

from sql-server-maintenance-solution.

Boran avatar Boran commented on July 1, 2024

To answer my own question, the reason was not to do with AGs, but the fact that LogShipping was also enabled on some DBs.
By setting @ExcludeLogShippedFromLogBackup='N' , this is now a LOG backup (in addition to log shipping, which is also a redundant backup of transactions)

from sql-server-maintenance-solution.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.