Built on hyperZip
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
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 tree goes in. The source is only ever read — never moved, deleted or rewritten.
Every block is unpacked and every file hash checked. Fail here and the archive is discarded.
Only now: one readable JSON entry, written atomically, carrying the archive's sha256.
The stored hash must match before the bytes are trusted. Rotted bytes are refused, not returned.
The case this tool was built against
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.
| Content | Size | Share | Files | Compressible? |
|---|---|---|---|---|
| Video (mp4, mov, avi) | 103.42 GiB | 53.7 % | 4,605 | No — already compressed |
| Mail (mbox) | 43.70 GiB | 22.7 % | 22 | Yes — plain text, enormous files |
| Photographs (JPEG) | 18.28 GiB | 9.5 % | 14,857 | Partly — lossless JPEG recoding |
| Archives (zip, gz, deb, img) | 8.57 GiB | 4.5 % | 246 | No — opaque |
| Other extensions | 7.39 GiB | 3.8 % | 11,927 | Mixed |
| Structured data (JSON, HTML, CSV, LevelDB) | 4.58 GiB | 2.4 % | 11,575 | Yes |
| No extension | 3.51 GiB | 1.8 % | 145,551 | Yes — and 75 % of all files |
| Documents and PDF | 3.11 GiB | 1.6 % | 4,375 | Partly |
What happened when it met a snapshot tool
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.
| 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
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.
| 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
hz unpack archive.hz target/ still
restores them. No custom container, no catalog required.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".hzbackup exclude-file prints the managed
paths for exactly that handoff. See
where it is going.Getting started
# 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
hzbackup run restic backup ~ \ --exclude-file <(hzbackup exclude-file) \ --compression max restic backup ~/.local/share/hzbackup/archives
Commands
add | put trees under management |
|---|---|
forget | stop managing; archives are kept |
run | pack what changed, verify each archive |
status | trees, sizes, savings, last run |
list | stored versions with sha256 |
restore | unpack a version, hash-checked first |
verify | sha256 and hz -t; --quick for sha256 only |
prune | drop versions beyond the keep count |
manifest | the catalog as JSON, absolute paths |
plugins | installed storage backends |
push | ship archives to a backend, read back and verified |
exclude-file | managed paths, one per line |
Plugins
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.
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
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.
Catalog, versions, restore, verify, prune, and the restic handoff. 18 assertions against a scratch store.
plugins, push, the plaintext gate, and
hZsvärm as an erasure-coding destination.
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.
The backend interface already carries this; what it is missing is a repository worth shipping through it.