Skip to main content

Crate bestool_kopia

Crate bestool_kopia 

Source
Expand description

Shared helpers for interacting with the kopia CLI.

Used by bestool-tamanu (for the kopia_backup doctor check) and by bestool (for the bestool kopia subcommand suite). Has nothing tamanu-specific in it.

Highlights:

Structs§

DirSummary
RootEntry
Snapshot
A single kopia snapshot, as emitted by kopia snapshot list --json.
SnapshotFilter
Filter criteria used by listing/restore/mount.
SnapshotSource

Enums§

Elevation
What to do about elevation on Linux when we want to run kopia.

Constants§

LINUX_KOPIA_CONFIG
Standard location of the system kopia repository config on Linux. Owned by the LINUX_KOPIA_USER.
LINUX_KOPIA_USER
System user that owns the Linux kopia install.

Functions§

build_filter
Build a SnapshotFilter from CLI-shaped inputs. all = true drops any source-host filter.
build_kopia_command
Build a Command that runs the kopia binary, elevated to the kopia user if the current platform/user requires it (Linux only).
current_username
Current process’s username (via whoami). None if whoami can’t determine it (rare).
fetch_snapshots
Run kopia snapshot list --json --all and parse the result.
find_kopia_binary
Locate the kopia binary.
find_windows_kopia_binary
Look for the kopia binary bundled with KopiaUI on Windows.
find_windows_kopia_config
Standard per-user kopia repository config on Windows, used by KopiaUI.
format_snapshot_line
One-line summary of a snapshot, suitable for an interactive picker.
format_tags
Render a snapshot’s tag map as a k=v, k2=v2 string (sorted by key).
format_taken
Format a snapshot timestamp for human display.
human_bytes
Human-readable size formatter.
linux_elevation
Decide how to invoke kopia on Linux given the current user and whether the system kopia install is present (and accessible).
parse_tag_kv
Parse a key:value tag spec from a --tag flag.
short_id
Kopia’s manifest IDs are long hex. The short prefix is enough to identify a snapshot in a list; kopia restore/mount accept short prefixes too.