Skip to Content
ConfigurationCompactor Mode

Overview

The compactor merges older incremental backups into new full snapshots, reducing storage usage and improving restore performance. It reads compaction policies from the cloud configuration file.


Manual Usage

# Dry-run (default) — prints planned actions without modifying anything xreplicator compact --repo /var/lib/backup/repo # Actually perform compaction xreplicator compact --repo /var/lib/backup/repo --dry-run=false # Use a custom cloud config xreplicator compact --repo /var/lib/backup/repo --cloud-config /etc/xreplicator/cloud-config.yaml
FlagRequiredDefaultDescription
--repoYesRepository path
--cloud-configNo<repo>/cloud-config.yamlCloud config path
--dry-runNotruePrint actions without modifying snapshots

Compaction Policies

Policies are defined in cloud-config.yaml under the compaction.policies section.

Policy Parameters

ParameterTypeRequiredDescription
namestringYesUnique policy name
enabledbooleanEnable/disable this policy (default: true)
compact_to_fullbooleanCreate a new full snapshot from compacted incrementals (default: true)
rpodurationYesCompact snapshots older than this value (e.g., "24h")
keep_snapshotsintegerNoMinimum recent snapshots to keep, even if older than RPO
hostnamesstring[]NoExact hostnames to match
hostname_globsstring[]NoGlob patterns for hostnames (e.g., ["prod-*"])
device_pathsstring[]NoExact device paths to match
device_path_globsstring[]NoGlob patterns for device paths

Use either hostnames or hostname_globs — not both. Same applies to device_paths vs device_path_globs.


How Compaction Works

  1. Policy Evaluation — Reads all enabled policies from the cloud config
  2. Snapshot Selection — Finds snapshots matching hostname/device criteria
  3. Age Filtering — Filters snapshots older than the RPO, respecting keep_snapshots
  4. Compaction — Merges selected incrementals into a new full snapshot
  5. Cleanup — Deletes old incrementals that were compacted
  6. Chain Update — Updates parent links in remaining snapshots

Configuration Examples

Daily Compaction (All Devices)

compaction: policies: - name: "daily-compaction" enabled: true compact_to_full: true rpo: "24h" keep_snapshots: 10 hostname_globs: ["*"] device_path_globs: ["*"]

Weekly Compaction (Production Servers)

compaction: policies: - name: "weekly-production" enabled: true compact_to_full: true rpo: "168h" # 1 week keep_snapshots: 5 hostnames: ["prod-server-01", "prod-server-02"] device_paths: ["/dev/sda"]

Multiple Policies

compaction: policies: - name: "daily-all" enabled: true compact_to_full: true rpo: "24h" hostname_globs: ["*"] device_path_globs: ["*"] - name: "weekly-production" enabled: true compact_to_full: true rpo: "168h" keep_snapshots: 10 hostname_globs: ["prod-*"] - name: "monthly-archive" enabled: true compact_to_full: true rpo: "720h" # 30 days keep_snapshots: 3 hostname_globs: ["archive-*"]

Scheduling with systemd Timer

If you want scheduled compaction, create your own systemd timer that runs the xreplicator compact command from the backup-server package.

You can also schedule compaction from the Web UI: go to Settings and configure the compaction schedule there. You can also create and edit compaction policies directly from the UI.

Last updated on