Expand description
Backup planning. Pure functions that take service install state + the user’s backup config and produce typed plans the CLI executes.
What lives here:
BackupRunPlan: everything the CLI needs to push one service’s data to the configured restic repository.BackupRestorePlan: same shape for the reverse operation.plan_backup_run/plan_backup_restore: the planners.
What does not live here: spawning the restic subprocess, running
hook scripts, or any other side effect. The CLI layer owns those.
Keeping the planner pure means it round-trips cleanly in tests
against a tempdir without needing restic on the test runner.
Structs§
- Backup
Forget Plan - Instructions for pruning one service’s snapshots to the retention ladder.
Built from the configured retention policy; the CLI spawns
restic forget(then--pruneto reclaim space) scoped to this service’sservice:<name>tag, so one service’s policy can’t evict another’s snapshots. - Backup
Restore Plan - Instructions for restoring one installed service from a specific restic snapshot.
- Backup
RunPlan - Concrete instructions for backing up one installed service.
Functions§
- backup_
stops_ service - Whether backing up this service stops it. Cold services (the default) take a
stop-the-stack snapshot;
onlineservices snapshot live. Surfaced to the UI so “Back up now” can warn about the brief downtime. - execute_
backup_ restore - Run a planned restore end-to-end.
- execute_
backup_ run - Run a planned backup end-to-end.
- list_
backup_ enabled - List installed services that have
backup_enabled = truein their metadata. The CLI’sryra backup manual(no service argument) uses this to iterate every enabled install. - manifest_
sha256 - Hex SHA256 of the service’s
service.toml. Used as themanifest_sha:tag on each snapshot so a future restore can detect version skew between the snapshot and the currently-installed service definition. - parse_
env_ file - KEY=VALUE lines from a
.envfile; malformed lines are skipped the same way systemd’s EnvironmentFile= skips them. - plan_
backup_ restore - Plan a
ryra backup restore <service>invocation. - plan_
backup_ run - Plan a
ryra backup manual <service>invocation. Errors loudly when: - plan_
mode_ prune - Plan a per-mode prune for one service: keep at most
keepsnapshots taggedmode:<mode>(the daily or weekly cap), dropping the oldest beyond that. Manual snapshots are never pruned, so callers only passdaily/weekly. ReturnsOk(None)whenkeep == 0(unlimited) rather than running a keep-nothing forget. - restic_
backup - Execute a planned backup with restic. Ownership of container-owned
bind mounts is the pre-hook’s job (
podman unshare chown); by this point every file is readable by the invoking user. - restic_
forget - Execute a planned retention sweep, returning
(kept, removed)snapshot counts. Runsrestic forget --jsonfiltered to the service’sservice:<name>tag (so keep rules apply only to that service), parses the keep/remove decision, then runsrestic pruneSEPARATELY to reclaim space (real runs only, when something was actually removed). Splitting prune out keeps the--jsonoutput clean to parse. In a dry run nothing is deleted andremovedis the count that WOULD be removed. - restic_
restore - Execute a planned restore. Files come back owned by the invoking
user; the next container start’s
:Ure-chowns to the container’s USER. (Running insidepodman unsharewould preserve snapshot UIDs but fails chowning/homeoutside the namespace mapping.) - restore_
stops_ service - Whether restoring this service stops it. A cold restore always stops the
stack to wipe + replace its data; an
onlineservice stops only if it ships restore hooks (e.g. it pauses the app while re-importing a dump). Surfaced to the UI so the restore confirm can warn about downtime. - run_
hook - Run a pre/post backup or restore hook with the service’s
.envloaded, mirroring how quadlet ExecStartPre/Post scripts see it. - set_
backup_ enabled - Enroll or unenroll a service in backups by flipping
backup_enabledin itsmetadata.toml. Returns whether the flag actually changed (falseif the service isn’t installed, or was already in that state). This on-disk flag is whatlist_backup_enabledand a no-argumentryra backup manualread, so it is the single source of truth both the CLI picker and the rpc layer set.