7.3 KiB
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.gzfile on disk with strict0600permissions and unit tests passing. - Components:
bin/linux-backuperlauncher andlinux_backuper/cli.py(snapshotcommand).- Basic OS detector (
core/detector.py). - Stub inspector that records hostname, OS, and timestamp.
- Basic archiver using standard library
gzip+tarfilepackaging into/tmp/linux-backuper-test/. - Enforced
0600archive permissions. - Unit tests verifying CLI execution, exit codes, and archive structure.
- Verification:
python3 -m unittest tests/test_cli.pypasses 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.
- Multi-distro package managers:
- 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 (quickdefault,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, strict0600file modes, optional--no-compression(plain.tar), diagnostic sanitization (--sanitize).core/manifest.py: generatesmanifest.jsonwith metadata, statistics, and SHA-256 hashes.- Atomic write protection: write to
.tmpfile first, compute hash, and atomically rename to finalbackup_<host>_<timestamp>.tar.gz. - Concurrency lock (
core/lock.py) using non-blockingfcntl.flockon/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-rundisplaying diff change plan and exit code5. - Mandatory
--forcerequired 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).
- Default
- 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 prunewith--dry-runsupport. - 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 (viaparamiko), andrsync. - Local-first guarantee: local snapshot is verified before initiating transfer; network errors do not corrupt local archive.
- Remote retention pruning engine.
- Transport abstraction (
- 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-updaterpackaging pipeline. - Components:
packaging/build_packages.py: pure Python Debian.debbuilder and RPM spec generator.packaging/install.sh: installer for generic.tar.gzdistribution.
- Verification: Build test packages locally and verify package structure with
tar -tvfandar -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
-hand--helpfor root and all sub-commands with usage examples. .gitea/workflows/release.yml: Gitea Actions pipeline targetingruns-on: fedora(hostexecutor runnergiteaworker), 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 viaPACKAGES_GENERATIONtoken, 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 withman -l man/linux-backuper.8.