Skip to content

Add retention config for snbk - #1179

Open
jameslai-dev wants to merge 2 commits into
openSUSE:masterfrom
jameslai-dev:dev-snbk-retention-config
Open

Add retention config for snbk#1179
jameslai-dev wants to merge 2 commits into
openSUSE:masterfrom
jameslai-dev:dev-snbk-retention-config

Conversation

@jameslai-dev

@jameslai-dev jameslai-dev commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

This PR adds retention-policy and retention-config entries to the snbk BackupConfig.
The retention-policy supports default and custom options. The default policy is designed to keep the snapshots on the backup device identical to those on the source device (the existing behavior); the custom policy requires an additional configuration entry retention-config, which defines the cleanup behavior.

The parameters under the retention-config section share the same names as snapper configuration options (NUMBER_LIMIT, TIMELINE_LIMIT_HOURLY, ...), so that the cleanup parameter class (the Parameters class in client/cleanup.cc) can load the config without a major interface modification.

An example config:

{
  "config": "test",
  "target-mode": "local",
  "target-path": "/mnt/test-btrfs-target/.snapper/data",
  "automatic": false,
  "retention-policy": "custom",
  "retention-config": {
    "NUMBER_MIN_AGE": "3600",
    "NUMBER_LIMIT": "50",
    "NUMBER_LIMIT_IMPORTANT": "10",
    "TIMELINE_MIN_AGE": "3600",
    "TIMELINE_LIMIT_HOURLY": "48",
    "TIMELINE_LIMIT_DAILY": "14",
    "TIMELINE_LIMIT_WEEKLY": "12",
  }
}

Additional changes:

  • A specialized get_child_value function is added to the JsonFile module to support parsing a JSON node into a string-to-string dictionary.

Things to discuss:

  • The style of cleanup parameters (NUMBER_LIMIT, TIMELINE_LIMIT_HOURLY, ...) does not match the existing snbk configuration style (target-mode, target-path, ...). It's fine with me, but I'm not sure what others think.

Parent issue: #1105

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.

1 participant