Skip to main content

Module backup

Module backup 

Source
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:

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§

BackupRestorePlan
Instructions for restoring one installed service from a specific restic snapshot.
BackupRunPlan
Concrete instructions for backing up one installed service.

Functions§

execute_backup_run
Run a planned backup end-to-end: pre hook, restic, post hook. The post hook runs even when restic fails (it usually cleans up a dump file), but its own failure never masks restic’s error.
list_backup_enabled
List installed services that have backup_enabled = true in their metadata. The CLI’s ryra backup run (no service argument) uses this to iterate every enabled install.
manifest_sha256
Hex SHA256 of the service’s service.toml. Used as the manifest_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 .env file; 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 run <service> invocation. Errors loudly when:
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_restore
Execute a planned restore. Files come back owned by the invoking user; the next container start’s :U re-chowns to the container’s USER. (Running inside podman unshare would preserve snapshot UIDs but fails chowning /home outside the namespace mapping.)
run_hook
Run a pre/post backup or restore hook with the service’s .env loaded, mirroring how quadlet ExecStartPre/Post scripts see it.