Skip to main content

pack

Function pack 

Source
pub fn pack(
    data_dir: impl AsRef<Path>,
    out_path: impl AsRef<Path>,
) -> Result<u64>
Expand description

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.

That safety is a property of what lives down there, not of the skip. subdirectories_are_derived_spill_only pins the set, so a future directory of TRUTH cannot join the data dir without someone reading this first.

use kevy_cli::backup::pack;
let data = kevy_tmpdir::TmpDir::new("pack-data");
std::fs::write(data.path().join("dump-0.rdb"), [7u8; 100])?;
std::fs::create_dir(data.path().join("tier"))?; // derived spill: not packed
let out = kevy_tmpdir::TmpDir::new("pack-out");
let bundle = out.path().join("b.kevybkp");
assert_eq!(pack(data.path(), &bundle)?, 100, "body bytes packed");
// never overwrites an existing backup
assert!(pack(data.path(), &bundle).is_err());