Linux System Backuper (linux-backuper)
An enterprise-grade, deterministic Linux system snapshot, configuration backup, and safe restoration utility written in pure Python >= 3.6 with zero mandatory external pip dependencies.
linux-backuper captures the comprehensive state of a Linux host—including hardware profiles, storage layout (LVM, partitions, mountpoints), network configuration, installed packages, kernel parameters, and configuration trees (/etc/)—into self-contained, cryptographically verifiable archives with time-bucket retention and local-first remote synchronization.
Table of Contents
- Key Features
- Architecture & Guarantees
- Installation
- Quick Start
- Core CLI Commands
snapshot- Creating Snapshotslist- Listing Snapshotsshow- Deep Manifest & State Inspectiondiff- Live Configuration Drift Detectionextract- Selective Single-File Extractionrestore- Safe System State Restorationprune- Retention Policy Enforcementsync- Remote Storage Synchronizationcompletion- Shell Tab Completions
- Automation & Systemd Integration
- Security & Guardrails
- Documentation Triad
- License
Key Features
- Zero External Dependencies: Runs natively out of the box on standard Python 3.6+ without requiring
pip install, virtualenvs, or external wheels. - Fast Pre-Indexed Archives: Single
.tar.gzarchive with embeddedmanifest.jsonplaced as the first entry in the tar stream, enabling sub-millisecond metadata reads without decompressing the full archive. - Broad Linux Distribution Support: Tested and verified across Debian 11/12/13, Ubuntu 20.04/22.04/24.04, RHEL/AlmaLinux/CentOS Stream 8/9/10, Fedora 40+, and Arch Linux.
- Safe Restoration Engine:
- Dry-run by default (exit code 5) prevents accidental state modifications.
- Mandatory
--forceflag required for active filesystem changes. - Automatic
pre_restore_<timestamp>safety snapshot before any file modification. - Atomic file replacement (
.tmpwrite followed by rename) and automatic SELinux label restoration. - Protection against restoring
/etc/fstab(requires explicit--include-fstab) and dynamic mounts (/proc,/sys,/dev,/run).
- Comprehensive State Inspector: Collects OS release, package inventory (
rpm,dpkg,pacman), system services (systemctl), user/group tables, block devices (lsblk,lvs), network interfaces and routes, sysctl values, and hardware telemetry. - Time-Bucket Retention (GFS): Pruning policies supporting
--keep-last,--keep-daily,--keep-weekly, and--keep-monthlywith independent local and remote retention rules. - Local-First Remote Sync: Snapshots remain securely on the host first, then sync to remote SSH/rsync targets or NFS/SMB storage with resume support and atomic directory updates.
- Diagnostic Sanitization:
--sanitizeflag automatically redacts password hashes, shadow entries, API tokens, and private SSL/SSH keys for safe off-host diagnostic sharing.
Architecture & Guarantees
linux-backuper/
├── core/
│ ├── archiver.py # Tarball streamer, zip-slip defense, manifest indexer
│ ├── inspector.py # Hardware, OS, package manager, network, and storage inspector
│ ├── profiles.py # Profile manager (quick, system, full, custom)
│ ├── diff.py # Unified diff engine and filesystem drift detector
│ ├── restore.py # Safe atomic restore, pre-restore snapshots, SELinux relabel
│ ├── retention.py # Grandfather-Father-Son (GFS) time-bucket pruning engine
│ ├── transport.py # Local-first remote transport sync (rsync, scp, local)
│ ├── lock.py # System flock concurrency controller (/var/run/linux-backuper.lock)
│ └── completions.py # Native bash/zsh shell auto-completion generator
└── cli.py # Section-8 compliant command-line interface
Snapshot Archive Layout:
snapshot_<hostname>_<timestamp>.tar.gz
├── manifest.json # Stream position 0: Metadata, inspector telemetry, SHA-256
└── data/ # Preserved directory tree with exact mode, uid, gid, mtime
└── etc/
├── nginx/...
└── systemd/...
Installation
Debian / Ubuntu (.deb)
From the Gitea Package Registry:
sudo curl -fsSL https://gitea.wired.synology.me/api/packages/soda64/debian/repository.key \
-o /etc/apt/trusted.gpg.d/gitea-wired.asc
echo "deb [signed-by=/etc/apt/trusted.gpg.d/gitea-wired.asc] https://gitea.wired.synology.me/api/packages/soda64/debian stable main" \
| sudo tee /etc/apt/sources.list.d/gitea-wired.list
sudo apt update
sudo apt install linux-backuper
Or install downloaded .deb package directly:
sudo dpkg -i linux-backuper_1.0.0_all.deb
RHEL / AlmaLinux / Fedora (.rpm)
From the Gitea Package Registry:
sudo tee /etc/yum.repos.d/gitea-wired.repo << 'EOF'
[gitea-wired]
name = Wired LAB Gitea RPM Repository
baseurl = https://gitea.wired.synology.me/api/packages/soda64/rpm
enabled = 1
gpgcheck = 0
EOF
sudo dnf install linux-backuper
Or install downloaded .rpm package directly:
sudo rpm -ivh linux-backuper-1.0.0-1.fc44.noarch.rpm
Universal Installer Script
Use the standalone POSIX-compliant installer provided with releases:
tar -xzf linux-backuper-1.0.0.tar.gz
cd linux-backuper-1.0.0
sudo ./packaging/install.sh --install
To uninstall:
sudo ./packaging/install.sh --uninstall
Manual / Standalone Tarball
Because linux-backuper is pure Python, you can run it directly without installation:
tar -xzf linux-backuper-1.0.0.tar.gz
python3 linux-backuper-1.0.0/bin/linux-backuper --version
Quick Start
# 1. Create a routine configuration snapshot
sudo linux-backuper snapshot
# 2. List all existing snapshots
linux-backuper list
# 3. Detect live configuration drift against the latest snapshot
linux-backuper diff latest
# 4. Extract a single modified file without unpacking everything
sudo linux-backuper extract latest --file /etc/hosts --out /tmp/hosts.restored
# 5. Simulate restoration with dry-run protection (exit code 5)
sudo linux-backuper restore latest --dry-run
Core CLI Commands
snapshot - Creating Snapshots
Creates a compressed snapshot archive containing configuration trees and system state telemetry.
# Quick profile (default, covers /etc)
sudo linux-backuper snapshot --profile quick
# System profile (covers /etc, /boot, and kernel telemetry)
sudo linux-backuper snapshot --profile system
# Full disaster recovery profile (covers /etc, /boot, critical /var)
sudo linux-backuper snapshot --profile full
# Custom directory targets
sudo linux-backuper snapshot --paths /etc/nginx /etc/ssl /var/www/config
# Diagnostic export with credential redaction
sudo linux-backuper snapshot --sanitize
# Snapshot with immediate remote upload and retention enforcement
sudo linux-backuper snapshot \
--push backupuser@nas.lan:/volume1/backups \
--keep-last 7 --keep-daily 14
list - Listing Snapshots
Displays a formatted table of all local snapshot archives in /var/backups/linux-backuper/.
linux-backuper list
Sample output:
SNAPSHOT ID PROFILE FILES SIZE CREATED
snapshot_alma-crash_20261009_2015 quick 1,420 14.2 MB 2026-10-09 20:15:22
snapshot_alma-crash_20261009_1200 system 2,185 48.7 MB 2026-10-09 12:00:01
show - Deep Manifest & State Inspection
Reads the front of the archive to display recorded host telemetry, storage mounts, network state, and packages.
# General host telemetry and snapshot metadata
linux-backuper show latest
# List all packages installed at the time of the snapshot
linux-backuper show latest --packages
# List all files archived in the snapshot
linux-backuper show latest --files
diff - Live Configuration Drift Detection
Compares files and packages between the live running host and a snapshot, or between two different snapshots.
# Compare live filesystem against the latest snapshot
linux-backuper diff latest
# Output unified diff (context patches) for modified files
linux-backuper diff latest -u
# Compare two specific snapshots against each other
linux-backuper diff snapshot_host_20261001_1200 snapshot_host_20261009_1200
extract - Selective Single-File Extraction
Extracts an individual configuration file from an archive without decompressing or restoring the rest of the snapshot. Protected against Zip Slip path traversal.
sudo linux-backuper extract latest --file /etc/nginx/nginx.conf --out /tmp/nginx.conf.bak
restore - Safe System State Restoration
Restores files from a snapshot back into the host filesystem.
# 1. Preview changes (Dry-Run by default, exits with code 5)
sudo linux-backuper restore latest --dry-run
# 2. Live execution (Requires --force, auto-creates pre_restore_<ts> safety snapshot)
sudo linux-backuper restore latest --force
# 3. Restore including /etc/fstab (Skipped by default for safety)
sudo linux-backuper restore latest --force --include-fstab
prune - Retention Policy Enforcement
Applies Grandfather-Father-Son (GFS) time-bucket pruning to retain only required snapshots.
# Simulate pruning plan
sudo linux-backuper prune --keep-last 5 --keep-daily 7 --keep-weekly 4 --dry-run
# Apply pruning plan
sudo linux-backuper prune --keep-last 5 --keep-daily 7 --keep-weekly 4 --force
sync - Remote Storage Synchronization
Synchronizes local snapshot archives to remote storage using SSH/rsync or local network mounts.
# Sync over SSH/rsync with remote pruning
sudo linux-backuper sync \
--target backupuser@nas.lan:/volume1/backups/ \
--remote-keep-last 14 --remote-keep-daily 30
# Sync to a mounted NFS / SMB path
sudo linux-backuper sync --target /mnt/nas/backups/
completion - Shell Tab Completions
linux-backuper includes built-in tab completion generators for bash and zsh:
# Bash completion
sudo linux-backuper completion bash | sudo tee /etc/bash_completion.d/linux-backuper
# Zsh completion
linux-backuper completion zsh > ~/.zsh/completion/_linux-backuper
Automation & Systemd Integration
linux-backuper packages ship with native systemd timer and service units for scheduled snapshots:
-
Service Unit (
/usr/lib/systemd/system/linux-backuper.service): Executes automated snapshots and retention pruning:[Unit] Description=Linux Backuper Automated Snapshot and Prune After=network.target [Service] Type=oneshot ExecStart=/usr/bin/linux-backuper snapshot --profile quick --keep-last 7 --keep-daily 14 -
Timer Unit (
/usr/lib/systemd/system/linux-backuper.timer): Runs daily at 02:00 with randomized delay:[Unit] Description=Daily Linux Backuper Trigger [Timer] OnCalendar=*-*-* 02:00:00 RandomizedDelaySec=15m Persistent=true [Install] WantedBy=timers.target -
Enable & Start:
sudo systemctl daemon-reload sudo systemctl enable --now linux-backuper.timer sudo systemctl list-timers linux-backuper.timer
Security & Guardrails
- Strict Access Control: Local snapshots are created with
0600file modes in/var/backups/linux-backuper/(accessible only by root). - Concurrency Locking: Employs non-blocking
flock(2)on/var/run/linux-backuper.lockto prevent overlapping snapshot or restore operations. - Path Traversal Shield: All extraction and restoration paths are normalized and verified against base target directories to mitigate Zip Slip and symlink exploits.
- SELinux Relabeling: When restoring on SELinux-enforcing systems (RHEL, AlmaLinux, Fedora), automatically invokes
restorecon -Ron modified paths. - Mount & Device Protection: Refuses to touch virtual filesystems (
/proc,/sys,/dev,/run) or socket nodes.
Documentation Triad
For complete documentation, refer to the guides in the docs/ directory:
- 📖 User Guide: Daily operational guide for sysadmins, DevOps, and operators.
- ⚙️ Administrator Guide: Systemd setup, GFS retention strategies, remote NAS sync, and JSON health monitoring.
- 💻 Developer Guide: Architecture deep dive, zero-dependency engine standards, test suites, and packaging workflows.
- 📜 UNIX Man Page: View the Section 8 manual with
man linux-backuper.
License
This project is licensed under the MIT License - see the LICENSE file for details.