feat(docs): implement slice 8 documentation triad, man page, completions and Gitea Actions CI/CD
Build and Publish Release / test-and-release (push) Failing after 48s

This commit is contained in:
soda64 committed 2026-10-09 20:22:51 +02:00
1 parent c5c3b87bd9
commit 6f23f14b76
14 files changed
+1730 -10

No files matched your search

+177
View File
@@ -0,0 +1,177 @@
# linux-backuper User Guide
Welcome to the **linux-backuper** user guide. This document explains how operators and system users can create snapshots, inspect system telemetry, compare configuration drift, extract individual files, and safely restore system states.
---
## 1. Overview & Key Concepts
`linux-backuper` is an enterprise Linux system snapshot and configuration backup utility written in pure Python >= 3.6 with zero mandatory external pip dependencies.
### Key Highlights:
- **Fast Single-Archive Format:** Snapshots are single `.tar.gz` archives with a pre-indexed `manifest.json` at the front of the archive stream, allowing instant listing and metadata inspection without unpacking.
- **Root-Only Security:** Every snapshot is created with strict `0600` permissions (root read/write only) in `/var/backups/linux-backuper/`.
- **Safe Restoration Engine:** Full restores require `--force`, run a dry-run plan by default (exit code 5), automatically create a `pre_restore_*` safety snapshot before touching any file, use atomic file replacement, and protect dynamic system mounts and sockets.
---
## 2. Creating Snapshots
Snapshot creation is performed using `linux-backuper snapshot`:
```bash
sudo linux-backuper snapshot [OPTIONS]
```
### Backup Profiles
`linux-backuper` comes with pre-configured backup profiles:
| Profile | Target Paths | Use Case |
| :--- | :--- | :--- |
| `quick` *(default)* | `/etc/` | Routine configuration backups, daily cronjobs, fast pre-upgrade snapshots. |
| `system` | `/etc/`, `/boot/`, kernel state | Pre-kernel upgrade, bootloader changes, driver updates. |
| `full` / `dr` | `/etc/`, `/boot/`, high-value `/var/` (crontabs, systemd state, NetworkManager) | Full disaster recovery baseline before major OS migration. |
#### Examples:
```bash
# Quick configuration snapshot (default)
sudo linux-backuper snapshot --profile quick
# System boot and configuration snapshot
sudo linux-backuper snapshot --profile system
# Snapshot specific custom paths
sudo linux-backuper snapshot --paths /etc/nginx /etc/ssl /var/www/config
# Store without gzip compression (plain tar)
sudo linux-backuper snapshot --no-compression
# Redact passwords, shadow hashes, and SSL private keys (for sharing diagnostics)
sudo linux-backuper snapshot --sanitize
```
---
## 3. Listing & Inspecting Snapshots
### Listing Local Snapshots
```bash
linux-backuper list
```
Outputs a formatted table showing snapshot IDs, creation dates, profiles, file counts, and archive sizes. Add `--json` for machine-readable output:
```bash
linux-backuper list --json
```
### Inspecting Snapshot Details
To inspect metadata, host hardware, kernel parameters, network interfaces, and storage mounts recorded at snapshot time:
```bash
linux-backuper show backup_host_20261009_120000
```
To list all package versions installed on the system when the snapshot was taken:
```bash
linux-backuper show backup_host_20261009_120000 --packages
```
To list every file archived in the snapshot:
```bash
linux-backuper show backup_host_20261009_120000 --files
```
---
## 4. Comparing System State (Diff Engine)
The diff engine detects configuration drift and package updates.
### Live System Diff
Compare the current running operating system against a past snapshot:
```bash
sudo linux-backuper diff backup_host_20261009_120000
```
This checks:
- Packages added, removed, or upgraded since the snapshot.
- Files added, modified, or deleted in configuration trees.
To inspect line-by-line differences in modified configuration files, use `-u` or `--unified`:
```bash
sudo linux-backuper diff backup_host_20261009_120000 --unified
```
### Snapshot-to-Snapshot Diff
Compare two distinct snapshots to see what changed between maintenance windows:
```bash
linux-backuper diff backup_host_20261001_100000 backup_host_20261009_120000 --unified
```
---
## 5. Selective Single-File Extraction
If an accidental edit broke a single configuration file (e.g. `/etc/ssh/sshd_config`), you do not need to restore the whole system. Extract the specific file directly:
```bash
sudo linux-backuper extract backup_host_20261009_120000 \
--file /etc/ssh/sshd_config \
--out /tmp/sshd_config.recovered
```
`linux-backuper extract` features strict Zip Slip / Path Traversal protection to ensure files are never extracted outside the requested output target.
---
## 6. Safe System Restoration
Full restores are protected by multiple safety guardrails:
### Step 1: Dry-Run Simulation (Default)
Running `restore` without `--force` prints a complete execution plan and exits with status code `5`:
```bash
sudo linux-backuper restore backup_host_20261009_120000 --dry-run
```
Output summarizes:
- Files to be updated, added, or deleted.
- Volatile sockets, FIFOs, and dynamic mounts skipped automatically (`/etc/resolv.conf`, `/etc/mtab`, `/run/`).
### Step 2: Live Restoration (`--force`)
When satisfied with the dry-run, execute the restore with `--force`:
```bash
sudo linux-backuper restore backup_host_20261009_120000 --force
```
### Safety Guarantees During Live Restore:
1. **Automated Safety Snapshot:** `linux-backuper` immediately captures a full `pre_restore_<timestamp>` snapshot before modifying any system file. If needed, you can roll back instantly.
2. **Atomic File Replacement:** Files are written to temporary staging files (`.linux_backuper_restore.*`) and moved into place via atomic `os.replace` to prevent corrupted configurations if interrupted.
3. **SELinux Auto-Relabeling:** On SELinux-enforcing systems (RHEL, AlmaLinux, CentOS, Fedora), `restorecon -R` is automatically executed on all restored trees to ensure correct security contexts.
4. **Fstab Safety Guard:** Restoring `/etc/fstab` is blocked by default to prevent boot failures. If you specifically intend to restore fstab, provide `--include-fstab`.
---
## 7. Cryptographic Integrity Verification
To verify that an archive has not been corrupted or tampered with:
```bash
linux-backuper verify backup_host_20261009_120000
```
This validates:
- The SHA-256 cryptographic digest against the embedded archive manifest.
- The gzip compression stream integrity.
- The tar entry checksums and header formatting.
---
## 8. Shell Autocompletion
`linux-backuper` supports full tab completion for Bash and Zsh, including automatic dynamic completion of snapshot IDs:
```bash
# Enable in current Bash session:
source <(linux-backuper completion bash)
# Persist system-wide for Bash:
linux-backuper completion bash | sudo tee /usr/share/bash-completion/completions/linux-backuper > /dev/null
# Persist for Zsh:
linux-backuper completion zsh | sudo tee /usr/share/zsh/site-functions/_linux-backuper > /dev/null
```