Skip to content

PBM-1718 Allow physical/incremental backup for MongoDB Enterprise edition#1285

Open
igroene with Copilot wants to merge 5 commits into
devfrom
copilot/fix-backup-agent-read-concern
Open

PBM-1718 Allow physical/incremental backup for MongoDB Enterprise edition#1285
igroene with Copilot wants to merge 5 commits into
devfrom
copilot/fix-backup-agent-read-concern

Conversation

Copilot AI commented Mar 12, 2026

Copy link
Copy Markdown

Physical and incremental backups were restricted to Percona Server for MongoDB (PSMDB) only, despite MongoDB Enterprise supporting the same $backupCursor/$backupCursorExtend aggregation stages. Additionally, even after relaxing that gate, the backup nomination list remained empty for Enterprise nodes because the enterprise flag was never propagated through the agent heartbeat mechanism.

Changes

pbm/version/version.go — Detect and permit Enterprise edition

  • Added Modules []string \bson:"modules,omitempty"`toMongoVersion(populated frombuildInfo`)
  • Added IsEnterprise() bool method — checks for "enterprise" in Modules
  • Relaxed FullPhysicalBackup() and IncrementalPhysicalBackup() to pass when either PSMDBVersion != "" or IsEnterprise():
    // Before
    if v.PSMDBVersion == "" { return false }
    // After
    if v.PSMDBVersion == "" && !v.IsEnterprise() { return false }
  • Updated BackupType() error messages to mention MongoDB Enterprise alongside PSMDB

pbm/topo/agent.go — Persist enterprise flag in agent heartbeat

  • Added IsEnterprise bool \bson:"ent,omitempty"`toAgentStat`
  • Updated MongoVersion() to restore Modules: []string{"enterprise"} from this flag — without this, getValidCandidates() and collectTopoCheckErrors() would reconstruct a MongoVersion with no Modules, causing IsEnterprise() to always return false and filtering out all Enterprise nodes as invalid backup candidates

cmd/pbm-agent/agent.go — Populate the enterprise flag on heartbeat

  • Set IsEnterprise: nodeVersion.IsEnterprise() when building the AgentStat heartbeat in HbStatus()

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@it-percona-cla

it-percona-cla commented Mar 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ igroene
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Explicitly set local read concern for $backupCursor and
$backupCursorExtend aggregate operations. These stages only support
local read concern, but the client may be configured with majority,
causing backup failures.

Co-authored-by: igroene <9805809+igroene@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with physical backup and unsupported read concern Fix physical backup failure when client read concern is not local Mar 12, 2026
Add enterprise edition detection to MongoVersion and update
FullPhysicalBackup() and IncrementalPhysicalBackup() to also
allow physical backups when MongoDB Enterprise is in use,
since it supports $backupCursor just like PSMDB.

Co-authored-by: igroene <9805809+igroene@users.noreply.github.com>
Copilot AI changed the title Fix physical backup failure when client read concern is not local Allow physical/incremental/external backup for MongoDB Enterprise edition Mar 12, 2026
AgentStat was missing the Enterprise edition flag, causing
MongoVersion() to reconstruct without Modules, making
IsEnterprise() return false during candidate filtering.

Add IsEnterprise bool field to AgentStat, populate it in
HbStatus(), and use it in MongoVersion() to set Modules.

Co-authored-by: igroene <9805809+igroene@users.noreply.github.com>
Copilot AI changed the title Allow physical/incremental/external backup for MongoDB Enterprise edition Allow physical/incremental backup for MongoDB Enterprise edition Mar 12, 2026
@igroene
igroene marked this pull request as ready for review March 13, 2026 11:17
Comment on lines +105 to +107
name string
ver MongoVersion
want bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[gofmt] reported by reviewdog 🐶

Suggested change
name string
ver MongoVersion
want bool
name string
ver MongoVersion
want bool

Comment thread pbm/backup/physical.go
}

cur, err := bc.conn.Database("admin").Aggregate(ctx, mongo.Pipeline{
cur, err := bc.conn.Database("admin", options.Database().SetReadConcern(readconcern.Local())).Aggregate(ctx, mongo.Pipeline{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
The line is 126 characters long, which exceeds the maximum of 120 characters. (lll)

@igroene igroene changed the title Allow physical/incremental backup for MongoDB Enterprise edition PBM-1718 Allow physical/incremental backup for MongoDB Enterprise edition Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants