Files

7.3 KiB

Gate 4 — Slice Plan: linux-backuper

This roadmap defines the implementation order for linux-backuper in thin, independently verifiable vertical slices.


Slice 1 — Tracer Bullet (Minimal End-to-End Wire)

  • Goal: Build the minimal working skeleton from CLI invocation to a verified .tar.gz file on disk with strict 0600 permissions and unit tests passing.
  • Components:
    • bin/linux-backuper launcher and linux_backuper/cli.py (snapshot command).
    • Basic OS detector (core/detector.py).
    • Stub inspector that records hostname, OS, and timestamp.
    • Basic archiver using standard library gzip + tarfile packaging into /tmp/linux-backuper-test/.
    • Enforced 0600 archive permissions.
    • Unit tests verifying CLI execution, exit codes, and archive structure.
  • Verification: python3 -m unittest tests/test_cli.py passes 100%.

Slice 2 — Comprehensive Host State Inspector (Deep Telemetry)

  • Goal: Implement full system introspection adapters for all 5 target distribution families.
  • Components:
    • Multi-distro package managers: managers/base.py, managers/rpm.py, managers/dpkg.py, managers/pacman.py.
    • User & Group accounts: /etc/passwd, /etc/group, /etc/subuid, /etc/subgid.
    • Storage inspector: partitions, filesystems (df -hT), block devices (lsblk -J + fallback), LVM (pvs/vgs/lvs).
    • Network inspector: interfaces (ip -j a), routing table (ip -j r), DNS resolvers (/etc/resolv.conf).
    • Hardware & Kernel: lscpu/uname, memory info, sysctl -a, /proc/cmdline, lsmod.
  • Verification: Unit tests verifying parser output against captured sample fixtures from Debian 12, Ubuntu 22.04, AlmaLinux 9, and Arch Linux.

Slice 3 — Profile System, Configuration Archiver & Manifest Generator

  • Goal: Safely bundle configuration trees with cryptographic integrity and profile selection.
  • Components:
    • core/profiles.py: built-in profiles (quick default, system, full) and custom profile loading from /etc/linux-backuper.json.
    • core/archiver.py: recursive collection of paths per profile, exclusion of runtime sockets/FIFOs/locks, strict 0600 file modes, optional --no-compression (plain .tar), diagnostic sanitization (--sanitize).
    • core/manifest.py: generates manifest.json with metadata, statistics, and SHA-256 hashes.
    • Atomic write protection: write to .tmp file first, compute hash, and atomically rename to final backup_<host>_<timestamp>.tar.gz.
    • Concurrency lock (core/lock.py) using non-blocking fcntl.flock on /var/run/linux-backuper.pid.
  • Verification: Test creating snapshots with all 3 profiles, verify checksum computation, and verify flock prevents double execution.

Slice 4 — Snapshot Management, Live Diff & Safe Restore Engine

  • Goal: Complete operator visibility, live system diffing, selective file recovery, and guardrailed full restoration.
  • Components:
    • linux-backuper list: tabular overview of local archives with sizes and status.
    • linux-backuper show <id>: pretty-print host metadata, storage, network, and package stats.
    • linux-backuper verify <id>: recalculate SHA-256 and confirm archive integrity.
    • linux-backuper diff <id>: live system diff comparing current host packages and /etc/ against snapshot.
    • linux-backuper diff <id1> <id2>: compare differences between two snapshot archives.
    • linux-backuper extract <id> --file <path> --out <dest>: selective single-file extraction without full unpack.
    • linux-backuper restore <id>:
      • Default --dry-run displaying diff change plan and exit code 5.
      • Mandatory --force required for live mutation.
      • Automatic pre_restore_<timestamp> safety snapshot captured before any file mutation.
      • Strict exclusion filter skipping sockets, FIFOs, and dynamic mounts (/etc/resolv.conf, /etc/mtab).
  • Verification: Unit and integration tests covering live diffing, selective extract, dry-run enforcement, automatic safety snapshot creation, and rollback verification.

Slice 5 — Retention Policy & Pruning Engine

  • Goal: Automatic lifecycle management for snapshots to prevent disk exhaustion.
  • Components:
    • core/retention.py: time-bucket pruning algorithms (--keep-last N, --keep-daily D, --keep-weekly W).
    • Prune CLI sub-command: linux-backuper prune with --dry-run support.
    • Automatic post-snapshot prune hook when configured in profile or config.
  • Verification: Unit tests with a set of 15 synthetic snapshot dates confirming correct retention calculations.

Slice 6 — Remote Transport Sync (Local-First Model)

  • Goal: Offload snapshots to remote network storage (e.g. Synology NAS) after local commitment.
  • Components:
    • Transport abstraction (core/transport.py): support for local folder / NFS / SMB mount, SFTP (via paramiko), and rsync.
    • Local-first guarantee: local snapshot is verified before initiating transfer; network errors do not corrupt local archive.
    • Remote retention pruning engine.
  • Verification: Tests verifying mock transport calls, remote retention execution, and network error handling.

Slice 7 — Native Packaging (.deb, .rpm, .tar.gz)

  • Goal: Enterprise packaging matching the linux-updater packaging pipeline.
  • Components:
    • packaging/build_packages.py: pure Python Debian .deb builder and RPM spec generator.
    • packaging/install.sh: installer for generic .tar.gz distribution.
  • Verification: Build test packages locally and verify package structure with tar -tvf and ar -t.

Slice 8 — Full Documentation, Man Page, CLI Help, Shell Tab Completion & Gitea Actions CI/CD Workflow

  • Goal: Production-ready release automation, complete documentation triad, man page, and native Bash/Zsh tab completion.
  • Components:
    • docs/user-guide.md: Comprehensive operator scenarios, routine backups, inspection, diffing, single-file extracts, and safe restore workflows.
    • docs/admin-guide.md: Automation via systemd timer/cron, /etc/logrotate.d/ rule, monitoring JSON integration, and remote SFTP/NFS retention.
    • docs/developer-guide.md: Internal architecture, extending package/storage managers, and testing runbook.
    • man/linux-backuper.8: Full UNIX Section 8 man page (man 8 linux-backuper).
    • Shell Tab Completion: Native Bash (completions/bash/linux-backuper) and Zsh (completions/zsh/_linux-backuper) scripts supporting subcommands, flags, profiles, and dynamic snapshot ID completion.
    • linux-backuper completion [bash|zsh] generator sub-command.
    • Interactive CLI Help: Complete -h and --help for root and all sub-commands with usage examples.
    • .gitea/workflows/release.yml: Gitea Actions pipeline targeting runs-on: fedora (hostexecutor runner giteaworker), running tests (python3 -m unittest discover tests), building .rpm/.deb/.tar.gz, publishing to Gitea RPM (/api/packages/{owner}/rpm/upload) & Debian (/api/packages/{owner}/debian/pool/stable/main/upload) Package Registries, linking packages via PACKAGES_GENERATION token, and uploading Release assets.
  • Verification: Unit tests verifying linux-backuper -h, sub-command --help, shell completion scripts generation (linux-backuper completion bash / zsh), and man page syntax verification with man -l man/linux-backuper.8.