Menu: Tools ▸ HAF ▸ Backup and Restore (window title Backup & Restore).
A safety net that complements git. Git protects committed code and project registry sources; it does not protect uncommitted edits, licensed source models, generated bakes, or the live BepInEx runtime files. The window captures both irreplaceable data and known-good generated versions, with five protections ranging from “I clicked the wrong thing” to “the machine burned down.”
| Layer | Trigger | What it writes | Retention |
|---|---|---|---|
| Manual version | Back up now button | Timestamped folder of the toggled groups + manifest | Never auto-deleted |
| Daily auto-version | First editor load of a day (>24 h since last; toggle, default ON) | Full backup of ALL groups — assets and configuration — on a background thread, same core as the button | Newest 3 _auto_ versions kept; rotation logged |
| Delete guard | Any asset deletion under a protected root (toggle, default ON) — excluding preview scratch, bake-test fixtures and the animated bake’s regenerated rig assets under anim/ |
_deleted_<timestamp>_<name>/ copy of the asset (+ .meta) before the delete proceeds |
Pruned after N days by the daily auto-version (field under the toggle; default 14, 0 = keep forever) |
| Offsite zip | Rides along with any manual/auto backup (optional: set the Offsite folder) | ONE HAF_<timestamp>.zip per backup, in a second — ideally cloud-synced — folder. Skipped entirely when nothing changed since the last upload (see Space) |
Never overwritten |
| Factory remove-undo | The Model Factory’s Remove (always) | _removed_<timestamp>_<name>/ with the entry’s JSON + the exact baked-output whitelist, taken BEFORE anything is deleted; restore via the Undo remove button next to Remove OR the window’s Factory remove snapshots section — both do the full restore (baked assets + registry entry) through one shared implementation |
Never auto-deleted |
Every local snapshot type feeds the same restorable list: manual, auto, pre-restore, delete-guard, and Factory-remove entries have a Restore button and the same safety guards. Offsite zips are disaster copies outside that list; copy or extract one back to an accessible backup location before restoring it.
Two snapshots taken 3.5 hours apart were compared file by file: 18 of 4,076 files differed. Every backup was
re-copying ~1.4 GB of which ~99.6% was byte-identical to the one before, and source alone — the licensed models,
which change rarely — is 971 MB of that. Two independent savings (2026-08-23), kept separate because they fail
differently:
Locally, unchanged files are hard-linked to the newest existing snapshot. A hard link is a second name for the
same bytes on the same volume, so an unchanged file costs zero additional space while each snapshot stays a
complete, independently browsable, independently restorable folder. Same idea as Time Machine or rsync --link-dest.
The first real run: 4,077 files, 3,966 hard-linked (1.2 GB saved), 111 copied (65.4 MB). “Unchanged” is
decided by content (review of PR #105): every snapshot writes an index of <length>|<sha1> per file
(haf_hashes.txt), and the next snapshot links a file only when the live file’s key equals the record — no size, no
last-write time however precise, because a tool that writes new bytes under a preserved timestamp defeats any such
rule. Each file is keyed at its own decision time, and the copy loop runs per file in parallel to afford that
(measured on Unity’s Mono: the 3 GB tree in 2.1 s on 8 cores, 12.8 s on one; reading the previous snapshot on the
backup drive would take 51 s, which is why the index exists). A key taken for the whole tree ahead of the loop would
be stale for a file edited while the loop still ran, and would link the previous version. The first backup after 2026-09-30 finds no index in the previous snapshot and links nothing that once — it
takes as long as a backup did before dedup — and every later one links by content.
Two consequences worth knowing. Explorer reports each snapshot at its full apparent size — it counts shared bytes once per name, so the folder still looks like 1.4 GB. And deleting an old snapshot frees only the blocks unique to it; the bytes survive while any other snapshot still names them. Both are normal, and both mean keeping old snapshots is now nearly free.
The rule that makes it safe: never write INTO a snapshot folder. Editing a hard-linked file edits every snapshot sharing it. Nothing in HAF does — restore copies out of a snapshot into the live tree, and the delete-guard copies in from the live tree to a fresh folder — so neither writes through a link. Deleting is always safe. If the backup root ever moves to a different volume, linking silently degrades to full copies: costs space, never correctness.
Offsite, an unchanged snapshot is not uploaded at all. Each zip is a full ~1 GB, and daily uploads of the same
models fill a 15 GB cloud quota in about a week. A SHA-1 over every file’s relative path and content key (from the
snapshot’s own index — no second read) and over the manifest’s original paths (where a restore puts each source back)
is written into each snapshot (haf_signature.txt) and beside each uploaded zip (.sig); a matching signature means
the existing zip already is this backup — same bytes, same destinations — so the zip is skipped. Two snapshots of
the same bytes for the same originals sign the same whenever they were taken; a moved project signs differently (until PR #105 the signature took each file’s
mtime, and the manifest’s — which differs per snapshot — with it, so no two snapshots ever signed the same and the
skip never fired). An absent or unreadable signature always proceeds: “I don’t know” must never be read as
“unchanged”. The sidecar is written only after the zip is verified and moved into place, so a crash mid-zip cannot
leave a signature claiming an upload that never landed.
Both destinations used to be created on demand. Found live on 2026-08-23: the offsite folder was renamed and nothing anywhere said a word — the next backup would have silently recreated it and reported “Offsite: zipped N files → …”, a completely successful-looking line about a folder nothing syncs.
Both also warn in the window the moment the path is missing, not only in the status line after a run — because the daily auto-version runs unattended and nobody would ever read it.
Each group is an independent toggle with a live size readout (the daily auto-version always takes ALL groups):
| Group | Source |
|---|---|
| Editor scripts | Assets/Scripts/Editor |
| Source models | Assets/FactorySource (the bake inputs — licensed, irreplaceable, never shipped in the mod) |
| Baked assets | Assets/Resources (skeletons, atlases, clip collections, PNGs) |
| ENC Databases | Assets/Databases |
| Pack source | Assets/Pack/ — the model registry (<PackName>/pack.json) with the pack’s skins and sounds beside it. Since the 2026-08-19 collapse this git-tracked file IS the registry; the haf_packs copy under the game’s config (the Runtime config group) is a build artifact the editor ignores on load and overwrites on its next save. A backup without this group can bring the baked assets back but not the entries that name them. Added 2026-09-30 — older snapshots do not hold it, and a restore says so. |
| Tools | Tools/ (Blender rig/convert scripts, glbconv) |
| Runtime config | BepInEx/config/haf_*.json + haf_*.txt + community.humankind.haf.cfg + haf_packs/, haf_skins/, haf_sounds/, haf_ground_tex/, and haf_state/. Logs stay out; the regenerable haf_atlas_dump/ is skipped. The haf_packs copy is deployed recovery material—the project Assets/Pack/<PackName>/pack.json (the Pack source group) remains authoritative. |
Before anything under FactorySource / Databases / Scripts/Editor is deleted — the Factory’s Remove
flow, a Project-window delete, a script — it is first copied to a _deleted_<timestamp>_<name> folder with a
real manifest, so the Restore button puts it back in one click, including the .meta (the asset keeps
its GUID, so references to it survive the round trip). The restore’s own pre-restore snapshot covers only originals
that still exist; when the asset is simply gone, there is nothing to keep and the status says so (a restore whose
originals had been deleted used to abort on exactly that — review of PR #105). The delete then proceeds normally; the guard never blocks
anything — it only makes every deletion undoable. Same-second deletions of same-named assets get uniquified
folders (no silent merge).
Assets/Resources is deliberately not a guarded root (every re-bake deletes and rewrites its outputs; a
snapshot per bake would bury the list). The two flows that delete baked outputs on purpose take their own
snapshot instead, in the same _deleted_ shape: the Factory’s Remove (_removed_, below) and Ship Status’
Delete selected, which copies each name’s outputs (+ .meta) to _deleted_<timestamp>_<name>_outputs/
with a real manifest before sweeping them — a name whose snapshot cannot be taken is not deleted. Those folders
age with the guard’s (the same N-day retention); the window says so wherever it says “restorable”.
Assets/Resources is deliberately not guarded: the bake pipeline delete-firsts baked assets on every
re-bake (~30 delete sites), so guarding them would flood the backup root with churn within days — and bakes are
regenerable from FactorySource + config anyway. The daily auto-version still snapshots Resources for
go-back-a-version. Preview-scratch files are excluded too (*_PropFit.prefab, *_Preview.prefab,
*_PreviewMesh/_PreviewMat): the Lab’s fit preview delete-first rebuilds them constantly (“NOT shipped;
preview-only”), and logging that churn as deletions alarmed exactly the person the guard should reassure — the
guard protects what can’t be rebuilt, not what rebuilds itself.
Bake-test fixtures are excluded for the same reason (2026-08-23). Every run of the Bake Tests bakes assets under
a throwaway prefix (__smoketest__, __feat_, __convgate__) and deletes them again. Measured on the live backup
root: 362 guard folders totalling 6.4 GB across four days, 128 of them in one day, with __smoketest__ReconDrone
alone accounting for 1.9 GB as eight copies of the same 232 MB fixture. None of it could ever be worth restoring —
those assets exist to be deleted — and the volume made the window’s restorable list unreadable, which is the real
cost: a safety net nobody can see into is not a safety net. The exclusion references each suite’s own prefix
constant rather than a copy of the string, so a suite renaming its fixtures cannot silently restart the hoarding.
The animated bake’s regenerated rig assets are excluded too (2026-11-09). The rig import writes a rig prefab, the rig
meshes, a material per source material and a clip container per role under Assets/FactorySource/<name>/anim/ (or a
role folder anim_<role>/) and deletes them first on every bake. The T-62 has a hundred materials: 105 guard
snapshots per bake, each a folder, a copy, a manifest and a stack-traced Console line - most of the rig-import stage’s
7.4 seconds, for files the bake rewrites seconds later from the source beside them. The rule is the bake’s own,
BackupRules.IsRegeneratedRigAsset, used by the guard AND by the bake’s delete loop, so the guard lets go exactly what
the bake deletes: <name>_anim.prefab, <name>_rigmeshN.asset, <name>_rigmesh_atlasN.asset,
<name>_rigmatN.mat and _<name>_Clip_<role>.asset directly under anim/ or the bake’s named role folders.
N is a nonempty sequence of ASCII digits; a clip role must be nonempty (custom roles from the sidecar are supported).
The resource name must match the folder. Other materials, assets and prefabs in those folders remain guarded and
are left alone by the bake’s cleanup. Directories are always guarded, even when named like a generated file.
Nothing beside the rig folder (the source model, the albedos, the recorded arguments), above it or below it is
exempt. Blender’s slim .fbx in the same folder stays guarded.
Retention (2026-08-23). This was the one layer with none — every other layer rotates. Guard snapshots older than
N days are pruned by the daily auto-version; the field sits under the Delete guard toggle (default 14,
0 = keep forever, the original behaviour, still reachable for anyone who relied on it). By age, not count: a
guard’s worth is how recently it was made, and a burst of thirty deletions in one afternoon must not evict the single
one from yesterday that someone actually needs. Manual backups, _prerestore and the Factory’s _removed_ undo
snapshots are still never auto-deleted. Until 2026-10-31 this never ran once: the daily worker read the
retention pref from its background thread, where Unity’s EditorPrefs throws, and the faulted task said nothing (720
guards, 321 past the 14 days). The pref is read on the main thread now, the worker logs any throw, and every daily run
logs pruned N of M delete-guard snapshot(s); tools/check-worker-thread.py guards the shape in the push and CI.
A backup is a new folder <backup root>\<yyyy-MM-dd_HHmmss>\ (root is configurable and remembered; autos are
prefixed _auto_, guard snapshots _deleted_, pre-restore safety snapshots _prerestore_). Inside, each source
is copied under <group>/<name>, alongside a manifest.txt recording every source’s original absolute
path, file count, and byte size. Backups are never overwritten (each is a fresh timestamp). After copying,
the file count is re-verified against the manifest — a mismatch is flagged loudly, and a mismatched backup is
never used as a restore’s safety snapshot nor zipped offsite. Critical-content verify: a snapshot that took
the Pack source group must actually CONTAIN every registry source (Assets/Pack/*/pack.json), and one that took
the config group every deployed copy (haf_packs/*/pack.json), or the whole backup is marked not-ok with a loud
message — and “contain” means byte for byte the live file, not merely a file by that name (a hard link to an
older version would pass an existence check). A green backup literally says “registry source verified in snapshot (N pack.json)” (the recovery drill
found the registry silently absent from every backup for weeks; and until 2026-09-30 the backup verified only the
deployed copy while never taking the source at all). The verify is pure file IO over the groups’ paths, so it runs
for the daily auto-version too (its worker thread cannot touch Unity APIs — the earlier verify silently skipped
there), and a verify that cannot complete marks the backup not-ok rather than clean. A manual backup taken without
the Pack source group while one exists says “the registry SOURCE is NOT in this backup” instead.
Restoring the Pack source alone puts the registry back for the editor; the game reads the deployed copy
(haf_packs), which only a Model Factory save refreshes — the restore’s status says so. Restore the Runtime
config group from the same snapshot to bring both back together.
The list is grouped, every row starting with its date-time, newest first: Full backups (manual + daily auto), then Pre-restore, Delete-guard (open by default — the section you check after an “oops”), and Factory remove sections as counted foldouts. Restoring anything auto-refreshes every open Model Factory window — no manual Refresh after a restore.
The group checkboxes scope Restore exactly as they scope Backup (2026-08-17, closing the all-or-nothing gap:
recovering one thing from an older snapshot used to roll every other group back to snapshot time). Tick only
“Baked assets” + “Runtime config” and a restore touches nothing else — the confirm dialog states the scope.
_deleted and _prerestore snapshots restore whole (they are single-purpose by nature). Restore is also
smart: only files that are missing or actually different (byte-compared) are written — identical files
are left untouched (so Unity doesn’t re-import hundreds of unchanged assets) — and the status reports all three
counts (“Restored X missing + Y changed; Z identical untouched”). Restore reads the backup’s manifest and copies
each selected source back to its original path, never at the cost of current work:
_prerestore_<timestamp> backup. A wrong restore is always undoable — just restore
that snapshot.AssetDatabase.Refresh() reimports the restored assets.Delete removes a backup folder only (live files untouched), after a confirm.
D: is a second disk in the same machine — a machine-level event (theft, fire, surge) takes the backups with
the originals. The code is safe on GitHub; the source models and bakes are not. Set the Offsite folder
(ideally cloud-synced: OneDrive/Drive/NAS) and each backup is also written there as ONE HAF_<timestamp>.zip:
.partial then rename) and never overwritten — and self-recovering (2026-08-19, found
by the first end-to-end offsite verify): a domain reload (any recompile) kills the background zip thread
mid-write, which used to leave a stale .partial and a backup silently missing its offsite copy. On every
editor load, stale partials are cleaned up and any backup folder without its final zip is re-zipped
automatically (logged in the Console).AssetModificationProcessor) — a raw File.Delete from a
script or a deletion in Windows Explorer bypasses it. Nothing an editor script can catch; the daily
auto-version is the net under that net._deleted_ snapshots accumulate until the configured age retention prunes them (default 14 days; 0 keeps them
forever). The window’s Delete button remains the manual valve.Assets/Scripts/Editor (git-tracked in ENCReload since 2026-07-03), so its own
Editor scripts group is belt-and-braces — it still captures uncommitted editor-tool edits..meta files are copied with their assets, so restored assets keep their GUIDs/import settings.