Skip to content
manatoolsPublic

About

Manage btrfs snapshots and subvolumes with ease

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Manaradix — Btrfs Snapshot Management

A system utility for Linux distributions on Btrfs, providing a unified graphical and text interface for managing Btrfs snapshots, subvolumes, and filesystem parameters. Built on top of python-manatools using the aui (Abstract UI) backend so a single codebase renders in Qt, GTK, and ncurses frontends.

Conceptually similar to openSUSE's btrfsmaintenance + btrfs-assistant and Garuda's btrfs-assistant. Developed on Mageia (10 and Cauldron), which ships the reference RPM package, but it depends only on btrfs-progs, systemd, polkit, D-Bus, and GRUB — see Packaging for other distributions.

Screenshots

The Qt frontend. The same pages render in GTK and ncurses.

Dashboard Snapshots
Dashboard Snapshots
Policies Settings
Policies Settings
Setup Wizard About
Setup Wizard About

System Requirements

Dependency Minimum Notes
Python 3.11+ Core runtime
btrfs-progs 6.7+ /usr/bin/btrfs for all filesystem operations
python-manatools with the aui backend UI abstraction layer (GUI)
systemd 255+ Timers for automated snapshots
polkit 0.120+ Privilege escalation for non-root users
grub2 — Boot-from-snapshot support

Installation

Install the manaradix package from your distribution's repositories, e.g. on Mageia:

urpmi manaradix

The package installs the CLI/GUI launcher, man pages (man manaradix, man 5 manaradix-config), polkit rules, the setup profiles, the bus-activated D-Bus service, and the tray applet (a notification-area watchdog that autostarts at login and reports low disk space, device errors, and snapshots due for pruning). See docs/install.md and docs/tray-applet.md for details and post-install steps, and docs/packaging.md to package manaradix for another distribution.

Development Setup

A Python virtual environment is required for development. All commands below assume an activated venv.

# Clone the repository
git clone <repo-url> manaradix
cd manaradix

# Create and activate a virtual environment.
# --system-site-packages is required: runtime deps such as python-manatools
# and btrfs-progs are system packages and must stay visible from the venv.
python -m venv --system-site-packages .venv
source .venv/bin/activate       # Linux / macOS
# .venv\Scripts\activate        # Windows (untested)

# Install in editable mode with dev tools
pip install -e ".[dev]"

# Verify the install
manaradix --help

# Run the test suite (799 tests, 8 skipped)
pytest

# Run a single test file
pytest tests/test_snapshot_manager.py -v

# Run with coverage
pytest --cov=manaradix --cov-report=term

The tests use mocked subprocess calls — no live btrfs filesystem is required.

An integration suite in tests/test_integration_btrfs.py validates the parsers and the full snapshot lifecycle (create, list, rename, prune, browse, restore) against a real loopback btrfs filesystem. It needs root and is skipped in the normal run:

sudo -E .venv/bin/pytest tests/test_integration_btrfs.py -v

Python 3.11+ is the only hard Python dependency; btrfs-progs, systemd, polkit, python-manatools, and grub2 are system-level runtime dependencies needed only when running the actual tool. The UI renderer is tested against a fake widget factory, so no Qt/GTK/curses install is needed to run the suite.

If an existing venv predates the --system-site-packages switch, enable system package visibility by setting include-system-site-packages = true in .venv/pyvenv.cfg (no recreation needed).

Python dependencies

Package Version Purpose
tomlkit ≥ 0.12.0 TOML config file parsing (/etc/manaradix/config.toml)
pytest ≥ 8.0 Test runner (dev only)
pytest-cov ≥ 5.0 Coverage reporting (dev only)
python-manatools with the aui backend UI abstraction layer (GUI; often packaged as python3-manatools)

The Dashboard page shows disk usage per physical disk, a table of all btrfs filesystems (label, devices, sizes, free space, used percentage), a donut chart of internal Data/Metadata/System usage per filesystem (used, allocated-but-unused, and unallocated space), snapshot usage (total and exclusive bytes vs device size), recent snapshots, and active policies. When many disks or filesystems are present, dropdowns keep the view compact. It is the default tab on startup (the Setup Wizard is shown first instead when the system is unconfigured).

Quick Start

# Activate the venv first
source .venv/bin/activate

# Launch the GUI (requires python-manatools)
manaradix

# Or pick a specific frontend
manaradix --frontend ncurses

# Enable debug logging
manaradix --debug

# Use a custom config path
manaradix --config /etc/manaradix/config.toml

The GUI always re-executes via pkexec (polkit) so snapshot operations work from a normal user session. By default the UI backend is auto-detected — manatools recovers the display environment that pkexec strips, so the elevated GUI can still reach your desktop (Qt > GTK > ncurses). Pass --frontend {qt,gtk,ncurses} to force a backend; graphical frontends are probed first and fall back to ncurses with a warning if they cannot start. The flag maps to the MUI_BACKEND environment variable understood by python-manatools; you can set it directly instead (MUI_BACKEND=ncurses manaradix).

CLI Usage

When no subcommand is given, manaradix launches the GUI. Subcommands run headless and are suitable for scripts and systemd service units. The complete reference (every option, exit code, and the privilege model) is in docs/cli.md.

Create a snapshot

# Manual read-only snapshot of /
manaradix snapshot create

# Timed daily snapshot (tagged for retention pruning)
manaradix snapshot create --subvolume / --type timed --schedule daily

# Read-write snapshot with a description
manaradix snapshot create --subvolume /home --type manual \
    --read-write --description "Before dist-upgrade"

# Preview without executing
manaradix snapshot create --dry-run

List snapshots

# All snapshots on /
manaradix snapshot list

# Filter by subvolume
manaradix snapshot list --subvolume /home

Inspect a snapshot

manaradix snapshot info --id 2026-01-15_14-00-00

Delete a snapshot

manaradix snapshot delete --id 2026-01-15_14-00-00

# Preview
manaradix snapshot delete --id 2026-01-15_14-00-00 --dry-run

Prune old snapshots

The prune command uses the retention policy from your config file. It keeps the N most recent snapshots for the given schedule and deletes the rest.

# Prune daily snapshots for /, keeping the most recent <keep_daily>
manaradix snapshot prune --subvolume / --schedule daily

# Preview what would be deleted
manaradix snapshot prune --subvolume / --schedule daily --dry-run

This is the command invoked automatically by the systemd timer units — you normally don't run it by hand.

Automated activity status

The generated units record every run; this reports the current state of each scheduled tier:

manaradix activity status

Snapshot disk usage

manaradix usage status    # idle / running / ok / failed, with timestamps
manaradix usage show      # stored per-mount and per-snapshot sizes
sudo manaradix usage collect   # measure now (the daily timer does this)

Measuring snapshot usage can take minutes, so it runs in the background (manaradix-usage.timer) and the Dashboard shows the stored result with its last-update time. The Force Usage Data Update button starts a run without blocking the window. See docs/usage-tracker.md.

Safe snapshot removal

On btrfs, deleting a snapshot needs free metadata space — a full filesystem can refuse the very deletion that would free it. manaradix estimates the remaining headroom and warns before it runs out: a banner on the Snapshots page, a tray notification, and a warning from manaradix snapshot delete (which asks for --force when the estimate is critical). Scheduled pruning is never blocked. See docs/removal-safety.md.

First-run setup wizard

When the system has no snapshots and no snapshot policies (a fresh btrfs install), the GUI opens on a Setup Wizard tab proposing a setup profile for this system — desktop, server, or kiosk — auto-selected from the detected role (graphical → desktop, headless → server) and switchable from a dropdown. The plan is adapted to the actual layout: only btrfs subvolumes get policies, and boot snapshots / the GRUB recovery menu are only proposed when the root filesystem is btrfs (and GRUB is present). Apply it in one click, or configure everything manually from Policies and Settings.

The same setup is available headless — the full wizard/profiles documentation is in docs/profiles.md:

# Is setup needed?
manaradix setup status

# Which profiles are available?
manaradix setup list-profiles

# Apply the default profile (config, policies, systemd units, GRUB script)
manaradix setup apply

# Apply a specific profile, or preview what would be applied
manaradix setup apply --profile server
manaradix setup apply --dry-run

Profiles are TOML templates: the shipped ones live in /usr/share/manaradix/templates/, admin overrides and extras in /etc/manaradix/templates.d/.

Automated Snapshots (systemd Timers)

Manaradix can generate and manage systemd timer/service units that take snapshots on a schedule and automatically prune old ones.

  1. Create a config file at /etc/manaradix/config.toml:

    [global]
    default_subvolume = "/"
    snapshot_dir = ".snapshots"
    boot_from_snapshot = false
    
    [policies."/"]
    enabled = true
    schedule_hourly = false
    schedule_daily = true
    schedule_weekly = false
    schedule_monthly = false
    schedule_boot = false
    
    [policies."/".retention]
    keep_hourly = 10
    keep_daily = 7
    keep_weekly = 4
    keep_monthly = 3
    keep_boot = 5
  2. Apply the policy — this writes systemd units and enables the timers:

    from manaradix.core.policy_engine import PolicyEngine
    from manaradix.core.config_store import ConfigStore
    from manaradix.model.policy import SnapshotPolicy
    
    store = ConfigStore()
    store.load()
    policy = store.get_policy("/")
    engine = PolicyEngine()
    engine.apply_policy(policy)

    Or from the GUI: Policies → select a subvolume → Apply Policy.

The generated units (under /etc/systemd/system/) follow the naming pattern manaradix-snapshot-<subvol>-<schedule>.{service,timer} and invoke the CLI subcommands:

manaradix snapshot create --subvolume <X> --type timed --schedule <S>
manaradix snapshot prune --subvolume <X> --schedule <S>

Boot snapshots use a oneshot service (WantedBy=multi-user.target) instead of a timer, firing once per boot.

Boot-from-Snapshot (GRUB Integration)

Manaradix can install a GRUB script (/etc/grub.d/41_manaradix) that adds a "Manaradix Snapshots" submenu to the bootloader, listing read-only snapshots as bootable entries.

# From the GUI: Settings → GRUB Boot Menu → Install GRUB Script

# Or programmatically:
from manaradix.core.grub_integration import GrubIntegration
grub = GrubIntegration()
grub.install_script()
grub.update_grub()

Each entry boots with rootflags=subvol=.snapshots/<id>/root ro, giving you a read-only recovery environment.

Snapshot Storage Convention

Snapshots are stored under <mount>/.snapshots/<timestamp>/<subvol-name>/ with a JSON sidecar at info.json:

/.snapshots/
└── 2026-01-15_14-00-00/
    ├── info.json          # {"id": "...", "subvolume": "/", "type": "timed", ...}
    └── root/              # The actual btrfs snapshot subvolume

Configuration Reference

Default location: /etc/manaradix/config.toml (TOML format).

[global]

Key Type Default Description
default_subvolume string "/" Default subvolume path
snapshot_dir string ".snapshots" Snapshot storage relative to mount
boot_from_snapshot bool false Enable GRUB snapshot boot menu
snapshot_before_upgrade bool false Snapshot the root before every rpm package transaction

[policies."<subvolume>"]

Key Type Default Description
enabled bool true Whether the policy is active
schedule_hourly bool false Take hourly snapshots
schedule_daily bool true Take daily snapshots
schedule_weekly bool false Take weekly snapshots
schedule_monthly bool false Take monthly snapshots
schedule_boot bool false Snapshot on every boot

[policies."<subvolume>".retention]

Key Type Default Description
keep_hourly int 10 Hourly snapshots to retain
keep_daily int 7 Daily snapshots to retain
keep_weekly int 4 Weekly snapshots to retain
keep_monthly int 3 Monthly snapshots to retain
keep_boot int 5 Boot snapshots to retain
keep_pre_upgrade int 3 Pre-upgrade snapshots to retain

Snapshot Types

Type Description Read-only
manual User-created snapshot No
readonly User-created read-only snapshot Yes
timed Created by a systemd timer schedule Yes
boot Created at boot time Yes
pre-restore Safety snapshot taken before a restore Yes
pre-install Snapshot taken before package installation Yes
pre-upgrade Taken by the rpm file trigger before a package transaction Yes

Polkit Privilege Model

Four action levels under the org.mageia.manaradix.* namespace:

Action Who can perform Description
read Any user Query btrfs info (list snapshots, usage)
manage-snapshots auth_admin_keep Create, delete, restore, export snapshots
manage-policies auth_admin_keep Modify systemd timer units
manage-filesystem auth_admin_keep Scrub, balance, defrag, compression

The policy file is installed at /usr/share/polkit-1/actions/org.mageia.manaradix.policy.

D-Bus Service

A system-bus service (org.mageia.manaradix, object /org/mageia/manaradix) exposes the same core operations programmatically, authorizing each call against the four polkit action tiers above — the read tier needs no authentication, the manage tiers prompt the caller's polkit agent. The daemon runs as root and is bus-activated on demand (systemd unit + /usr/share/dbus-1/system-services/ descriptor); it is never enabled at boot and starts only when first called.

# Is the service running? (never activates it)
manaradix dbus status

# Run the daemon manually (root only; normally started by the bus)
sudo manaradix dbus serve

# Call a read method as any user
busctl --system call org.mageia.manaradix /org/mageia/manaradix \
    org.mageia.manaradix ListSnapshots s /

# A manage-tier call prompts for authorization (or fails with
# org.mageia.manaradix.Error.AuthRequired if denied)
busctl --system call org.mageia.manaradix /org/mageia/manaradix \
    org.mageia.manaradix CreateSnapshot sssbsssb / "" true manual "" / false

The daemon is a thin shell over the same core services as the CLI (manaradix/dbus/service.py — no business logic), so every method maps 1:1 to an existing library call. The manaradix.dbus.client module wraps the bus for Python callers, translating D-Bus errors into typed exceptions and offering a daemon_running() probe that never activates the service.

Files shipped: data/systemd/manaradix-dbus.service (unit), data/dbus/org.mageia.manaradix.service (activation descriptor), data/dbus/org.mageia.manaradix.conf (bus policy: anyone may call, polkit gates each method).

Tray Applet

A notification-area watchdog for the user session (manaradix tray serve, autostarted at login via /etc/xdg/autostart/manaradix-tray.desktop). It reads the system D-Bus service — including GetDeviceStats, which merges the btrfs error counters with UDisks2 SMART data when available — and:

  • notifies when a Btrfs filesystem drops below the configured free-space thresholds (warn 85 % / critical 95 % used, both configurable);
  • notifies on btrfs error counters and failing SMART health;
  • suggests pruning snapshots that are already past their retention tier budget (the same numbers snapshot prune uses);
  • reminds when no scrub is recorded for a filesystem;
  • opens a menu when the icon is clicked — Open manaradix, Check now, About, Quit — rather than launching the GUI straight away;
  • shows a tray icon that stays readable on dark panels (a light plate variant, since the plain black logo disappears on GNOME's top bar);
  • stays visible and clickable even when everything is fine (set hide_when_ok = true in [tray] to hide the healthy icon instead), respects quiet hours, and is a read-only observer — it never modifies anything itself.

All checks are individually switchable in the [tray] section of /etc/manaradix/config.toml. The applet ships in the same package and is never elevated (user-session process, _SESSION_COMMANDS in manaradix/utils/pkexec.py). See docs/tray-applet.md and docs/activity-tray-applet.md / docs/activity-tray-menu.md.

Project Structure

manaradix/
├── pyproject.toml
├── mkdocs.yml                      # Documentation site (MkDocs) configuration
├── README.md
├── spec.md                         # Full technical specification
├── CLAUDE.md                       # Contributor orientation
├── data/
│   ├── polkit/                     # Polkit policy XML
│   ├── desktop/                    # .desktop launcher + tray autostart
│   ├── systemd/                    # manaradix-dbus.service unit
│   ├── dbus/                       # Bus activation + bus policy files
│   ├── libexec/                    # manaradix-pre-upgrade rpm trigger
│   ├── images/                     # Logo (SVG + PNG)
│   ├── screenshots/                # UI screenshots
│   └── templates/                  # Setup profiles (desktop/server/kiosk)
├── docs/                           # Documentation site + design docs
├── locale/                         # gettext translations (it.po, .pot)
├── manaradix/
│   ├── __init__.py
│   ├── module.py                   # AppContext, run_app(), main() CLI
│   ├── i18n.py                     # gettext domain + _()
│   ├── model/                      # Data classes: Snapshot, Subvolume, Policy
│   ├── core/                       # Business logic (no UI imports)
│   │   ├── btrfs_ops.py            # /usr/bin/btrfs CLI wrapper
│   │   ├── snapshot_manager.py     # Snapshot lifecycle + journal
│   │   ├── policy_engine.py        # systemd unit generation
│   │   ├── grub_integration.py     # /etc/grub.d/41_manaradix
│   │   ├── config_store.py         # /etc/manaradix/config.toml
│   │   ├── setup_wizard.py         # First-run detection + profile apply
│   │   ├── templates.py            # Setup profile loader/validator
│   │   ├── activity_status.py      # Automated snapshot run records
│   │   ├── health.py               # Merged health report (btrfs + SMART)
│   │   ├── health_sources.py       # btrfs device stats + UDisks2 SMART
│   │   └── assets.py               # Logo path resolution
│   ├── dbus/                       # System D-Bus service + client
│   │   ├── constants.py            # Interface + method→polkit-action map
│   │   ├── convert.py              # Model ↔ D-Bus value conversion
│   │   ├── errors.py               # Typed client exceptions
│   │   ├── polkit.py               # GI Polkit authorization checks
│   │   ├── service.py              # Per-method logic (auth + delegation)
│   │   ├── wire.py                 # dbus.service.Object + serve_main()
│   │   └── client.py               # Python client library
│   ├── tray/                       # Notification-area applet (SNI)
│   │   ├── app.py                  # TrayApp wiring + worker thread
│   │   ├── checks.py               # space/devices/retention/scrub checks
│   │   ├── status_icon.py          # StatusNotifierItem icon
│   │   ├── dbus_menu.py            # DBusMenu model (open/check/quit)
│   │   ├── notifier.py             # Freedesktop notifications
│   │   └── scheduler.py            # Finding tracking + nag cadence
│   ├── ui/                         # Declarative UI (toolkit-agnostic)
│   │   ├── navigation.py
│   │   ├── model.py                # PageModel / Widget descriptor factories
│   │   ├── renderer.py             # Descriptor → manatools YUI widgets
│   │   └── pages/
│   │       ├── dashboard.py        # Dashboard (disk/fs/snapshot stats)
│   │       ├── snapshots.py        # Snapshot management
│   │       ├── policies.py         # Policy editor
│   │       ├── settings.py         # Global settings + maintenance
│   │       ├── setup.py            # First-run setup wizard page
│   │       └── about.py            # About: author, license
│   └── utils/
│       └── pkexec.py               # pkexec re-exec for privileged ops
└── tests/                          # 36 test files, 799 tests

Architecture Principles

Frontend-agnostic (no UI imports in business logic), CLI-first (every operation is a library call), idempotent operations, dry-run support, and journaled changes — see spec.md §4 and the development docs.

Translations

User-visible strings are marked with _() for gettext translation.

# Generate / update the template
xgettext --language=Python --keyword=_ --from-code=UTF-8 \
    --output=locale/manaradix.pot \
    --package-name=manaradix --package-version=0.3.1 \
    manaradix/module.py manaradix/utils/pkexec.py manaradix/i18n.py \
    manaradix/core/*.py manaradix/dbus/*.py manaradix/tray/*.py \
    manaradix/ui/renderer.py manaradix/ui/navigation.py \
    manaradix/ui/pages/*.py

# Create a new translation (example: Spanish)
msginit --locale=es --input=locale/manaradix.pot \
    --output-file=locale/es.po

# Update an existing translation after regenerating the template
msgmerge --update locale/it.po locale/manaradix.pot

# Compile a translation for testing
msgfmt locale/it.po -o locale/it/LC_MESSAGES/manaradix.mo

# Test with a specific locale
LANG=it_IT.UTF-8 MANARADIX_LOCALE_DIR=./locale manaradix snapshot list

Italian and Chinese (simplified) translations ship at locale/it.po and locale/zh_CN.po; other languages are welcome. The translation template is at locale/manaradix.pot. System-installed .mo files go to /usr/share/locale/<lang>/LC_MESSAGES/manaradix.mo, compiled and installed by the RPM spec (msgfmt + %find_lang).

Translations are managed on Transifex (resource manaradix in the Mageia project, alongside dnfdragora and manafirewall); anyone can join the language team there. locale/.tx/config maps the resource to locale/<lang>.po; with the tx CLI:

cd locale
tx push -s          # upload manaradix.pot after regenerating it
tx pull -a          # fetch every translation into locale/<lang>.po

The RPM spec compiles every locale/*.po, so pulled languages ship without spec changes.

Desktop-file strings (Name, GenericName, Comment, Keywords of data/desktop/*.desktop) are a second resource, manaradix_desktop (locale/desktop/.tx/config), handled like dnfdragora's: the translations are written straight into the committed desktop files by tools/desktoppo.py (needs polib, in the dev extra), so nothing runs at build time.

cd locale/desktop && tx pull -a && cd ../..   # fetch locale/desktop/<lang>.po
python3 tools/desktoppo.py -d data/desktop    # regenerate the pot, merge the
                                              # .po files, add Key[lang]= lines
cd locale/desktop && tx push -s               # upload the pot after a desktop
                                              # string changes

Documentation

User guide, CLI/configuration references, and the D-Bus interface are in docs/ — rendered as an MkDocs site with mkdocs serve from the repository root.

Development Note

manaradix is developed in spare time. AI-assisted tools are used to help with a portion of the development work; every change is reviewed, tested and maintained by the author.

License

Copyright © 2026 Matteo Pasotti xquiet@coriolite.com

GPLv2+ — see LICENSE.

About

Manage btrfs snapshots and subvolumes with ease

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages