Built on hyperZip

hZbackup

Verified cold-archive backup. Nothing is recorded as backed up until it has been proven to restore.

Backup tools compress and deduplicate generically. For cold trees — directories that no longer change, which is most of what a long-lived disk holds — a content-aware archiver does better, because it gets to see the whole tree at once instead of one chunk at a time. hZbackup packs those trees, proves each archive restores bit for bit, and then lets your snapshot tool move one file instead of a hundred thousand.

The rule the design turns on

An archive is not a backup until it has been unpacked again

Every pack is followed by hz -t, which unpacks every block and checks every file against its hash. A failed pack or a failed verification leaves the previous version in place and says so, rather than recording a version that does not exist.

The case this tool was built against

A 192.6 GiB archive that does not fit

Everything below is one real archive: 192.6 GiB in 193,158 files — two decades of mail, photographs, video and documents, consolidated out of five scattered source directories into one tree. It is what a long-lived disk accumulates and nobody ever opens again, and it is exactly where a general-purpose backup tool starts to hurt. Its content mix is the whole story, because hZ's advantage is not uniform.

File census of the archive, by extension group. Measured 2026-11-24. The two numbers that decide everything: half of it is already-compressed video, where no compressor can win — and nearly a quarter is plain-text mail in 22 enormous files, where whole-tree context is worth the most.
Content Size Share Files Compressible?
Video (mp4, mov, avi) 103.42 GiB53.7 % 4,605 No — already compressed
Mail (mbox) 43.70 GiB22.7 % 22 Yes — plain text, enormous files
Photographs (JPEG) 18.28 GiB9.5 % 14,857 Partly — lossless JPEG recoding
Archives (zip, gz, deb, img) 8.57 GiB4.5 % 246 No — opaque
Other extensions 7.39 GiB3.8 % 11,927 Mixed
Structured data (JSON, HTML, CSV, LevelDB) 4.58 GiB2.4 % 11,575 Yes
No extension 3.51 GiB1.8 % 145,551 Yes — and 75 % of all files
Documents and PDF 3.11 GiB1.6 % 4,375 Partly

What happened when it met a snapshot tool

The arithmetic that forces the whole design

The archive was finished at 08:27 one morning, inside a home directory that a nightly restic backup sweeps whole. The next run was due at 03:16. These are the numbers it would have met.

The free-space guard runs before the backup and compares against a 20 GB floor, so 111 GB free passes it cleanly. There is no second check during the run. The failure would therefore not have been a clean abort — it would have been a full root filesystem on a live machine, and a failed backup on top.
Going into the night Size  
Repository as it stood 177 GB already holding the rest of the home directory
Archive to be added 193 GB 53.7 % of it video, which does not compress
Would have needed ~356 GB the repository plus essentially the raw archive
Disk actually has 288 GB 177 used, 111 free
Shortfall 68 GB the disk fills and the backup dies

The answer is not a bigger disk. It is to stop re-scanning a cold 193 GiB tree every night: pack it once, prove the archive restores, and let the snapshot tool move one verified file instead of 193,158 unchanging ones. That is the whole thesis of hZbackup, and this archive is where it came from.

Measured dry-run once the tree was handed over: 233.3 GiB scanned, 10.8 GiB of new data — an ordinary night, comfortably inside the free space.

Measured against restic, not against tar.zst

Where whole-tree context actually pays

The comparison that counts is against what restic really writes — restic backup --compression max into a fresh repository — on the same machine, from samples cut out of the archive above.

Measurement in progress. Mail is measured; the other four classes are still running. Each class is a sample cut from the real archive, packed by restic and by hZ on the same machine (Ryzen AI 9 HX 470, 24 threads, NVMe). This table is generated by bench/tabell.py from results/pecka.json — never typed by hand, so it cannot drift from the run it reports.
Sample Raw restic --compression max hz normal hZ vs restic
Mail (mbox) 1,024 MiB 581 MiB 487 MiB −16.2 %
Structured data 300 MiB—— measuring
Documents and PDF 400 MiB—— measuring
Photographs (JPEG) 800 MiB—— measuring
Video (MP4) 812 MiB—— measuring

Why mail is the headline: restic splits a 20 GiB mailbox into roughly megabyte-sized chunks and compresses each one on its own, so almost no context crosses a chunk boundary. hZ gets the whole mailbox as one stream, where twenty years of repeated headers, quoted replies and signatures are all visible at once. −16.2 % on 43.70 GiB of mail is about 7 GiB — from the mail alone.

And the honest other half: on 103 GiB of H.264 video, no compressor beats any other, because the video codec already did the work. A tool that claimed a uniform win on this archive would be describing a different archive.

Guarantees

What it promises, and what it refuses

Proven restores, not recorded intentions proved
Every pack is followed by a full unpack-and-hash check. A failed pack or verification keeps the previous version and reports the failure.
The source tree is never touched proved
Not moved, not deleted, not rewritten. hZbackup only ever reads.
Archives are plain hyperZip archives proved
Lose this tool and hz unpack archive.hz target/ still restores them. No custom container, no catalog required.
A restore whose hash moved refused
The stored sha256 must match, or the restore is refused rather than handing you rotted bytes.
Unencrypted bytes sent to a destination that did not ask for them refused
Archives are plain hyperZip, so push stops unless the backend declares it accepts plaintext — or you type --plaintext-ok, which is the right amount of friction for "publish this readable to strangers".
Encryption, remotes, cross-tree chunk deduplication not built
Deliberately absent today. Pair hZbackup with restic, borg or a plain copy; hzbackup exclude-file prints the managed paths for exactly that handoff. See where it is going.

Getting started

Manage a cold tree

# needs Python 3.8+ and hz on the PATH
make install              # or PREFIX=~/.local

hzbackup add ~/photos-2019 ~/old-projects
hzbackup run                # pack what changed, verified
hzbackup status             # what it costs
hzbackup restore photos-2019 /tmp/check

Hand off to restic

hzbackup run
restic backup ~ \
  --exclude-file <(hzbackup exclude-file) \
  --compression max
restic backup ~/.local/share/hzbackup/archives

Commands

addput trees under management
forgetstop managing; archives are kept
runpack what changed, verify each archive
statustrees, sizes, savings, last run
liststored versions with sha256
restoreunpack a version, hash-checked first
verifysha256 and hz -t; --quick for sha256 only
prunedrop versions beyond the keep count
manifestthe catalog as JSON, absolute paths
pluginsinstalled storage backends
pushship archives to a backend, read back and verified
exclude-filemanaged paths, one per line

Plugins

A plugin is a destination, and nothing else

Drop a .py file exposing register() into ~/.local/share/hzbackup/plugins/. It gets Backend injected into its own namespace — hZbackup is one readable script, not an importable package, and the plugin contract is five methods: put, get, has, list, delete, plus an optional commit() for destinations that batch.

Narrow on purpose. A plugin system that can also replace the compressor is a format whose archives might not be readable on the next machine, and for a backup that is a risk, not a feature.

hZsvärm — erasure-coded distribution

The first plugin. It cuts the archive store into 32 MiB bands and Reed-Solomon codes each group of ten into twenty shards, so any 10 of 20 shards reconstruct all of it, with three holders per shard.

$ hzbackup push --to hzsvarm
refusing: hzsvarm does not accept
unencrypted bytes, and hzbackup archives
are plain hyperZip archives.

$ hzbackup push --to hzsvarm --plaintext-ok
pushed    t-20261124T094141.hz -> hzsvarm
          (1.9 MiB, read back and verified)
  encoded   generation 1  5.0 MiB,
            every stripe decode-proved

Where it is going

From a cold-archive packer to a repository

The direction is a snapshot repository of its own — what restic is, with hZ doing the compression. The measurement above is what makes that worth doing, and it also fixes the shape: compression happens in large blocks with whole-tree context, never per chunk. Chunking first and compressing each chunk alone is exactly what throws away the 16 % the mail sample shows. Everything below is not built yet.

  1. shipped
    Cold-tree packing, proved

    Catalog, versions, restore, verify, prune, and the restic handoff. 18 assertions against a scratch store.

  2. shipped
    Storage backends and the first plugin

    plugins, push, the plaintext gate, and hZsvärm as an erasure-coding destination.

  3. next
    A repository format

    Encryption, snapshots, and large-block compression with whole-tree context — so the 16 % survives instead of being chunked away. This is a format design, not an extension, and it needs its own plan before a line of it is written.

  4. later
    Remotes without a second tool

    The backend interface already carries this; what it is missing is a repository worth shipping through it.