How arelius-d/cerebro works
Purpose and entry points
Cerebro is a portable Linux backup suite centered on content-aware snapshot decisions rather than timestamp-only replication. The primary engine is cerebro.sh; it is configured by cerebro.cfg and runs manually or through a self-managed user cron entry. Recovery is provided by recall.sh, with an optional Python terminal UI in recall-tui.py. install.sh bootstraps a standalone installation.
Backup orchestration and isolation
cerebro.sh owns process lifecycle: dependency checks, per-script-name /tmp locking with stale-lock recovery, temporary workspace creation, EXIT cleanup, and guaranteed post-backup hook execution. The script directory is the instance boundary: local logs, temporary backups/, and assets/ metadata are instance-scoped, while destinations can be shared safely through hostname subdirectories.
Paths: cerebro.sh, cerebro.cfg
Configuration and safety gate
The INI-style configuration defines included live paths, exclusions, destinations, classification rules, scheduling, hooks, transfers, and retention. Before any work, the engine validates that every [CRUCIAL] rule is covered by [INCLUDE]; later, deletion of a previously backed-up crucial path aborts the new snapshot rather than committing an incomplete state.
Paths: cerebro.cfg, cerebro.sh
Snapshot discovery, staging, and comparison
Each run probes all configured destination/hostname directories, verifies candidate archives with tar -tzf under timeout, removes corrupted files, and selects the newest valid archive. It extracts that baseline into /tmp, stages a new tarball from live include paths, and compares old versus new state. [LOGDIFF] files receive unified content diffs in the execution log; [NOLOG] changes remain detectable but suppress verbose diff content.
Paths: cerebro.sh, cerebro.cfg
Decision, metadata, and archive integrity
The comparison classifies a candidate as no-change, RETAIN, or DISCARD:LATEST; no-change archives are removed, and crucial deletion exits nonzero. Backup classifications are persisted in assets/.tar_meta_data.txt (created at runtime) and drive later pruning. Final archives are standard gzip-compressed tar files and must pass a post-creation tar -tzf integrity check before distribution.
Paths: cerebro.sh, cerebro.cfg
Distribution, retention, and scheduling
Validated archives are copied to every reachable destination using retrying, timeout-bounded rsync, with cp -ru fallback. Unavailable mounts are isolated through responsiveness checks so other destinations can proceed. Retention removes superseded DISCARD archives and optionally age/count-expired RETAIN archives while preserving at least one backup; metadata is updated synchronously. The engine installs or updates its cron invocation based on [SCHEDULE].
Paths: cerebro.sh, cerebro.cfg
Recovery interfaces
recall.sh reads the same config, discovers the latest valid archive across destinations (or accepts --backup), searches archive members, and restores safely beside live paths using .bak/_bak suffixes. With no arguments or --tui, it delegates interactive archive browsing, previews/diffs, selection, and restoration to the curses-oriented Python UI. Recall keeps a separate local audit log.
Paths: recall.sh, recall-tui.py, cerebro.cfg
Runtime and external boundaries
The supported runtime is Bash 4+ on Linux plus GNU/POSIX utilities: tar, rsync, diff, gawk, timeout, grep, sed, and filesystem tools. Cron is the scheduling infrastructure; configured hooks may control Docker, databases, or other local services. Normal backup operation is offline and filesystem/mount based; network access is only material for optional installation or self-upgrade through GitHub.
Paths: install.sh, cerebro.sh, recall-tui.py
Main entry points: cerebro.sh Cerebro engine · recall.sh Recall CLI · cerebro.cfg Backup configuration · install.sh Installer
Components 21
Backup engine
Instance-scoped backup lifecycle.
- Backup configuration · Defines paths, rules, destinations, retention, hooks, and schedule.
cerebro.cfg - Cerebro engine · Manages locking, workspaces, cleanup, hooks, and backup flow.
cerebro.sh - Safety gate · Validates crucial coverage and aborts on crucial deletion.
cerebro.sh - Baseline discovery · Finds and validates the newest usable destination archive.
cerebro.sh - Snapshot staging · Extracts the baseline and creates a candidate archive from live paths.
cerebro.sh - Content comparison · Produces diffs and classifies no-change, RETAIN, or DISCARD:LATEST.
cerebro.sh - Archive metadata · Persists archive classifications for pruning.
cerebro.sh - Archive integrity check · Verifies the final gzip tar before distribution.
cerebro.sh - Distribution · Uses bounded rsync retries with cp fallback per reachable destination.
cerebro.sh - Retention pruning · Prunes superseded and expired archives while preserving one backup.
cerebro.sh - User cron management · Installs or updates the configured cron invocation.
cerebro.sh
Recovery
Archive discovery and safe restore.
- Recall CLI · Finds valid archives, searches members, and restores beside live paths.
recall.sh - Recall terminal UI · Browses, previews, diffs, selects, and restores archive content.
recall-tui.py - Recall audit log · Separate recovery activity log.
recall.sh
Runtime boundaries
Local tools, storage, and optional external access.
- Live included paths
- Destination mounts · Shared destinations are isolated by hostname subdirectories.
- Configured hooks · May coordinate Docker, databases, or other local services.
- Linux shell toolchain · Provides tar, rsync, diff, timeout, and filesystem operations.
- User cron
- GitHub · Used only for optional installation or self-upgrade.
Other components
- Installer · Bootstraps a standalone installation.
install.sh
Connections 27
- Installer → Cerebro engine: installs
- Installer → GitHub: optional download
- Backup configuration → Cerebro engine: configures
- Cerebro engine → Safety gate: validates first
- Safety gate → Baseline discovery: permits backup
- Backup configuration → Baseline discovery: destinations
- Destination mounts → Baseline discovery: candidate archives
- Baseline discovery → Snapshot staging: valid baseline
- Live included paths → Snapshot staging: included content
- Snapshot staging → Content comparison: old and candidate state
- Content comparison → Archive integrity check: retained candidate
- Content comparison → Archive metadata: classification
- Archive integrity check → Distribution: validated archive
- Distribution → Destination mounts: replicates
- Archive metadata → Retention pruning: pruning decisions
- Retention pruning → Destination mounts: removes archives
- Cerebro engine → Configured hooks: guaranteed post-backup
- Cerebro engine → User cron management: updates schedule
- User cron management → User cron: manages invocation
- User cron → Cerebro engine: runs
- Backup configuration → Recall CLI: configures
- Destination mounts → Recall CLI: archives
- Recall CLI → Live included paths: safe restore
- Recall CLI → Recall terminal UI: delegates interactive mode
- Recall CLI → Recall audit log: writes
- Linux shell toolchain → Cerebro engine: executes
- Linux shell toolchain → Recall CLI: executes