Skip to main content

Module backup

Module backup 

Source
Expand description

Backup / restore container support. See backup::pack and backup::unpack. kevy-cli backup / kevy-cli restore subcommands.

Backups bundle a kevy data_dir (snapshot + AOF) into a single .kevybkp file using a tiny custom container format (std-only, 0-dep — no tar crate per project rule).

Container format:

  magic        : 8 bytes = b"KEVYBKP1"
  for each file:
    name_len   : u16 big-endian
    name       : <name_len> bytes (UTF-8, relative to data_dir)
    body_len   : u64 big-endian
    body       : <body_len> bytes
  eof marker   : u16 = 0

Backup ordering: typically the operator issues a BGSAVE first against the live kevy via TCP, then runs kevy-cli backup once the snapshot has flushed. (kevy-cli backup can do this in one call too — see the --bgsave flag.)

Functions§

pack
Pack every regular file under data_dir into out_path. Subdirectories are skipped, and the data dir stopped being flat when tiering landed: tier/<shard>/vlog-*.dat holds demoted values and segs-<shard>/ holds cold index segments. Skipping them is correct because both are derived — a snapshot materialises cold values rather than referencing them, so the backup carries the data without the spill area and a restore rebuilds it — measured end to end against a store whose values had actually been demoted, not reasoned about.
run_backup
Wrapper around pack that accepts string paths for the CLI layer.
run_restore
Wrapper around unpack for CLI layer.
unpack
Unpack the container at in_path into target_dir (created if missing; refuses to overwrite an existing non-empty dir to avoid clobbering live data).