9.7 KiB
Gate 1 — Spec & Product: linux-backuper
1. Problem Statement & User Need
System administrators and homelab operators frequently perform system updates, package installations, network reconfigurations, or service migrations on bare-metal and virtual machines. When a configuration change breaks system boot, network connectivity, or application runtime, operators often face significant downtime because:
- Legacy backup scripts (like
etsy_backup.sh) are fragile bash scripts with hardcoded IP addresses, lack multi-distribution support, have no error handling or disk space checks, and do not prune old archives. - Full VM hypervisor snapshots (e.g. Proxmox snapshots) are storage-heavy and do not allow quick inspection of what specific configuration or package changed on the host.
- Configuration files in
/etcalone do not capture the running system context (which kernel was running, what disk/LVM layout existed, what IP routes were active, and which package versions were installed).
linux-backuper solves this by capturing a lightweight, self-contained host state snapshot: it packages the complete /etc configuration along with a structured machine-readable manifest of storage, networking, hardware, and package states. It provides instant inspection, checksum verification, selective file extraction, and automated retention pruning.
2. Success Metrics
- Zero External Dependencies: Runs out of the box on Python >= 3.6 on minimal installations of Debian, Ubuntu, RHEL 8/9, AlmaLinux, Rocky, Fedora, and Arch Linux without requiring
pip install. - Execution Speed & Lightweight Footprint: Takes less than 15 seconds to collect full host metadata and compress
/etcon a standard homelab VM. Archive size typically under 50 MB compressed. - Safety First: Performs pre-flight health checks (ensures >= 1 GB free space in backup target directory before capturing) and atomic writes (incomplete snapshots are cleanly rolled back and never left corrupted).
- Deterministic Snapshot Verification: Every snapshot includes a cryptographic SHA-256 manifest enabling 100% reliable verification of archive integrity and individual file hashes.
- Cross-Distro Package Introspection: Accurately dumps installed package names and versions across
rpm(RHEL/Fedora/Alma),dpkg(Debian/Ubuntu), andpacman(Arch). - Automated Pruning: Enforces configurable retention policies (e.g., keep last 7 daily snapshots, keep 4 weekly snapshots) without external cron/find scripts.
3. User Stories & Announcement
Announcement
"Announcing
linux-backuperv1.0.0 — the companion snapshot tool for Linux administrators and homelabbers. Before running dangerous upgrades or editing network configs, capture your host state in one command:linux-backuper snapshot. It bundles/etc, network routes, LVM layouts, and package lists into an authenticated archive with automatic pruning and remote NAS sync."
User Stories
- As a homelab administrator, I want to trigger a snapshot right before running
linux-updater update, so that if a service configuration is broken or overwritten, I can immediately diff or restore the previous/etc/files. - As an SRE/DevOps engineer, I want to schedule a daily system configuration backup via systemd timer to Synology NAS (SFTP/NFS), so that I have a disaster recovery record of how every VM was configured.
- As a system operator, I want to run
linux-backuper diff <snap1> <snap2>to see exactly which packages were upgraded or which config files changed between two points in time.
4. Screens & CLI Commands
# 1. Capture a full system snapshot with auto-generated name:
# 1. Capture snapshot with default profile (quick):
# sudo linux-backuper snapshot
[INFO] Profile: 'quick' (included: /etc, users/groups, full hardware/kernel/storage/network metadata)
[INFO] Pre-flight checks passed: 42.1 GB free in /var/backups/linux-backuper
[INFO] Collecting host metadata (hardware, storage, network, packages, kernel, users)...
[INFO] Archiving /etc directory with standard gzip compression...
[INFO] Generating SHA-256 integrity manifest...
[SUCCESS] Snapshot created: /var/backups/linux-backuper/backup_enterprise_20261002_211500.tar.gz (14.2 MB)
# 2. Capture full disaster-recovery snapshot and push to NAS:
# sudo linux-backuper snapshot --profile full --push nas
[INFO] Profile: 'full' (included: /etc, /boot, /var/spool/cron, /var/lib/systemd, /var/lib/NetworkManager, capped journal)
[INFO] Snapshot created locally: backup_enterprise_20261002_220000.tar.gz (48.1 MB)
[INFO] Transferring to remote 'nas' (SFTP: 192.168.10.2:/volume1/backups/hosts)...
[SUCCESS] Remote sync complete with remote retention applied.
# 3. Compare current live system with a previous snapshot:
# linux-backuper diff backup_enterprise_20261001_040000
Packages changed on live host:
+ nginx 1.24.0-1.el9 (installed since snapshot)
~ openssl 3.0.7-27.el9 -> 3.0.7-28.el9 (upgraded)
Configuration files modified on live host:
~ /etc/nginx/nginx.conf
+ /etc/nginx/conf.d/default.conf
# 4. Safe single file extraction:
# sudo linux-backuper extract backup_enterprise_20261001_040000 --file /etc/nginx/nginx.conf --out /tmp/nginx.conf.old
# 5. Full restore with mandatory safety guardrails:
# sudo linux-backuper restore backup_enterprise_20261001_040000
[WARN] Running in DRY-RUN mode. No live files will be modified without '--force'.
[PLAN] Files to be restored: 142 files modified, 3 files to be created.
[WARN] Network configuration (/etc/netplan/) would be altered!
Use 'linux-backuper restore backup_enterprise_20261001_040000 --force' to execute.
# sudo linux-backuper restore backup_enterprise_20261001_040000 --force
[INFO] Safety: Creating automatic pre-restore safety snapshot 'pre_restore_20261002_220500'...
[SUCCESS] Safety snapshot captured (42.0 MB).
[INFO] Restoring configuration files to live /etc/ (excluding sockets, locks, runtime mounts)...
[SUCCESS] Restore completed successfully. Pre-restore rollback available at 'pre_restore_20261002_220500'.
5. Scope & Constraints
- Zero Third-Party Pip Packages: Pure Python standard library (Python >= 3.6). Built-in
gzipandtarfilemodule. Optional--no-compressionflag. - Root Protection & Permissions:
- Creating snapshots, pruning, and live restoring strictly requires root (
os.geteuid() == 0). - Snapshot archives are created with strict
0600permissions inside0700directories. - Optional diagnostic sanitization (
--sanitize) redacts/etc/shadow,/etc/gshadow, and private keys (/etc/ssh/ssh_host_*_key).
- Creating snapshots, pruning, and live restoring strictly requires root (
- Profiles Architecture:
quick(default):/etc/, users/groups, full hardware/kernel/storage/network/package metadata.system:/etc/,/boot/, kernel cmdline/modules, systemd units, metadata.full:/etc/,/boot/,/var/spool/cron,/var/lib/systemd,/var/lib/NetworkManager, capped recent journal.- User-defined profiles in
/etc/linux-backuper.json.
- FHS Compliance:
- Executable:
/usr/bin/linux-backuper - Library:
/usr/lib/linux-backuper/ - Config:
/etc/linux-backuper.json - Default local backup directory:
/var/backups/linux-backuper/ - Logs:
/var/log/linux-backuper/
- Executable:
6. Documentation Deliverables & CLI Help Standards (Parity with linux-updater)
To guarantee consistency across the homelab tooling ecosystem, linux-backuper delivers four full documentation artifacts and a rich CLI help interface:
- User Guide (
docs/user-guide.md): Practical, scenario-driven walkthroughs for operators (routine backups, checking status, inspecting snapshot metadata, diffing configurations, selective single-file restores). - Administrator Guide (
docs/admin-guide.md): System administration, automated scheduling (systemd timer, cron), log rotation (/etc/logrotate.d/linux-backuper), monitoring integration (Prometheus/Zabbix/Wazuh JSON parsing), and remote NAS retention management. - Developer Guide (
docs/developer-guide.md): Codebase architecture, adding new system inspector modules, implementing storage backends, and executing containerized test suites. - System Manual Page (
man/linux-backuper.8): Full troff/groff UNIX Section 8 man page detailing all options, environment variables, exit codes, and examples. - Interactive CLI Help (
-h/--help):- Root
linux-backuper -houtputs an intuitive summary of all sub-commands with usage hints. - Each sub-command (
snapshot -h,list -h,show -h,diff -h,verify -h,extract -h,prune -h) provides full argument descriptions, default values, and concrete examples.
- Root
7. Shell Tab Completion (Bash & Zsh)
To provide a smooth, fast terminal experience in everyday administration, linux-backuper includes first-class shell completion:
- Command & Option Completion:
- Hitting
Tabafterlinux-backupersuggests all sub-commands (snapshot,list,show,diff,verify,extract,prune,completion). - Hitting
Tabafter flags suggests options (--keep-last,--keep-daily,--paths,--json,--verbose).
- Hitting
- Dynamic Context-Aware Completion:
linux-backuper show <Tab>\rightarrowautomatically inspects/var/backups/linux-backuper/and suggests availablesnapshot_idnames.linux-backuper diff <Tab>\rightarrowsuggests available snapshot IDs for comparison.linux-backuper extract <Tab>\rightarrowsuggests snapshot IDs, and after--file <Tab>suggests archived files.
- On-Demand Script Generation & System Packaging:
- Dedicated generator command:
linux-backuper completion [bash|zsh]outputs ready-to-source completion scripts. - System packages (
.deband.rpm) automatically install completions to/usr/share/bash-completion/completions/linux-backuperand/usr/share/zsh/site-functions/_linux-backuper.
- Dedicated generator command: