PostgreSQL backup retention should be at least 7 days

Medium Azure General postgres-backup-retention

Applies to

  • Microsoft.DBforPostgreSQL/flexibleServers

What CGPulse checks

A resource passes this rule when backup.backupRetentionDays must be greater than 6. Anything else is reported as a finding with the evaluated property value attached as evidence.

How to fix it

Set backup retention to at least 7 days for adequate data recovery options. In Azure Portal: PostgreSQL Flexible Server > Backup > set Retention period to 7+ days. See: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-backup-restore

CLI

az postgres flexible-server update --ids "{id}" --backup-retention 7

Bicep

resource pg 'Microsoft.DBforPostgreSQL/flexibleServers@2023-12-01-preview' existing = {{
  name: '{name}'
}}
// TODO: Update highAvailability.mode to 'ZoneRedundant'
// Note: This may require a specific tier (GeneralPurpose or MemoryOptimized)

Terraform

resource "azurerm_postgresql_flexible_server" "{name}" {
  name                   = "{name}"
  resource_group_name    = "{rg}"
  location               = var.location
  version                = "16"
  sku_name               = "B_Standard_B1ms"
  backup_retention_days  = 35
  # Max is 35 days for flexible servers
}

Compliance frameworks

Vendor documentation

Is your environment compliant with this rule?

CGPulse checks it — and 621 others — against your Azure and AWS accounts with read-only access.

Run a free scan

Related Azure rules

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.