hZtorrent — erasure-coded distribution of restic archives
restic encrypts, deduplicates and can be trusted. What it does not do is spread the result across many locations that fail independently. hZtorrent takes a restic archive — already encrypted, so nothing here ever sees plaintext — cuts it into fixed bands, Reed-Solomon codes each group into 20 shards and spreads them. Any 10 of the 20 shards are enough to restore everything.
Guarantees
- A stripe is registered only once it has been proven to decode. After encoding, shards are thrown away, the data is rebuilt from the rest and compared by hash. If that fails nothing is written, and the previous generation stays untouched.
- A shard does not count as placed until it has been read back from storage and hashed. A call that did not throw an error is not the same thing.
- A generation is refused if the archive changed while it was being read, rather than recording a half-consistent one.
- Restoring needs nothing but Python 3 and sha256. No signatures, keys or third-party packages, and the test suite enforces that by restoring with every third-party import blocked.
Measured
| value | why | |
|---|---|---|
| shards | any 10 of 20 restore all | half the shards hold all the information |
| band | 32 MiB | replacing a lost shard takes about 6 minutes on a 7.9 Mbit/s uplink; 256 MiB was measured and rejected at 25 minutes |
| shards reused between generations | 86 %, on every run | the band order is kept from the previous generation, so new data does not shift old bands |
| Reed-Solomon, hand-written | 194 MiB/s on 16 cores | a 6 GB vault encodes in about 30 seconds, so every run can afford a whole new generation |
The shard reuse took two fixes to get right. restic names its files by content hash, so a new file landed in a random position and shifted every band after it: one run reused 60 of 80 shards, the next none at all. With insertion order kept between generations, it is 86 % every time.
Honest about its limits
A swarm of friends shares an internet provider, a country and a Christmas holiday, so durability figures that assume independent failures would be lying. hZtorrent is an addition to the real offsite copy, never the plan. It also does not encrypt again: restic already did, and a second layer would only add a second key to lose.
The project is at an early stage. The code lives locally and is not published.