Skip to content

The agent that grows with you

fix(backup): exclude profile caches from full backups

Brad Estes3b3f354933ad
diff --git a/hermes_cli/backup.py b/hermes_cli/backup.py
index 6fa9f46f3dd..834dafceb9b 100644
--- a/hermes_cli/backup.py
+++ b/hermes_cli/backup.py
@@ -60,14 +60,16 @@ _EXCLUDED_DIRS = {
".cache", ".tox", ".nox", ".pytest_cache", ".mypy_cache", ".ruff_cache",
}
-# Hermes-managed runtime downloads (GGUF models, llama.cpp runtimes, managed Node): re-downloaded
-# on demand and routinely tens to hundreds of GB. Matched ONLY at the root of HERMES_HOME and at
-# ``profiles/<name>/`` — a deeper dir of the same name (a skill's ``models/``) is user data.
-_EXCLUDED_ROOT_DIRS = {"models", "runtimes", "node"}
+# Hermes-managed runtime downloads (GGUF models, llama.cpp runtimes, managed Node) and caches are
+# regenerable. Runtime trees routinely reach tens to hundreds of GB; live browser/tool caches may
+# also contain locked SQLite databases that cannot be snapshotted consistently. Match these names
+# ONLY at the root of HERMES_HOME and at ``profiles/<name>/`` — a deeper directory of the same name
+# (for example, a skill's ``models/`` or ``cache/``) is user data and must survive.
+_EXCLUDED_ROOT_DIRS = {"cache", "models", "runtimes", "node"}
def _in_excluded_root_dir(rel_path: Path) -> bool:
- """True when *rel_path* is, or sits inside, a managed runtime tree at a profile-home root."""
+ """True when *rel_path* is inside a regenerable tree at a profile-home root."""
parts = rel_path.parts
return bool(parts) and (
parts[0] in _EXCLUDED_ROOT_DIRS
diff --git a/tests/hermes_cli/test_backup.py b/tests/hermes_cli/test_backup.py
index abc5bf6dcb6..405fb1aa5a7 100644
--- a/tests/hermes_cli/test_backup.py
+++ b/tests/hermes_cli/test_backup.py
@@ -171,6 +171,13 @@ class TestShouldExclude:
assert _should_exclude(Path("profiles/clean/models/big.gguf"))
assert _should_exclude(Path("profiles/clean/runtimes/llamacpp/x.dll"))
+ def test_excludes_regenerable_cache_at_profile_roots(self):
+ """Live browser/tool caches are mutable and unsafe to snapshot."""
+ from hermes_cli.backup import _should_exclude
+ assert _should_exclude(Path("cache/chrome-debug/Default/Cookies"))
+ assert _should_exclude(Path("profiles/sage/cache/chrome-debug/cache.db"))
+ assert not _should_exclude(Path("skills/example/cache/notes.md"))
+
def test_keeps_nested_dirs_named_like_runtime_trees(self):
"""A deeper directory that happens to be called models/ or node/ is
user data (a skill's assets, project files) and must survive."""
@@ -232,6 +239,30 @@ class TestIterBackupFiles:
assert str(Path("models/big.gguf")) not in selected
assert not any(s.startswith("hermes-agent") for s in selected)
+ def test_prunes_profile_root_caches_but_keeps_nested_user_cache(self, tmp_path):
+ from hermes_cli.backup import _iter_backup_files
+
+ root = tmp_path / ".hermes"
+ root.mkdir()
+ root_cache = root / "cache" / "browser"
+ profile_cache = root / "profiles" / "sage" / "cache" / "browser"
+ nested_cache = root / "skills" / "example" / "cache"
+ for directory in (root_cache, profile_cache, nested_cache):
+ directory.mkdir(parents=True)
+ (directory / "state.db").write_bytes(b"cache contents")
+
+ skipped: set = set()
+ selected = {
+ str(rel)
+ for _, rel in _iter_backup_files(root, tmp_path / "out.zip", skipped)
+ }
+
+ assert str(Path("cache/browser/state.db")) not in selected
+ assert str(Path("profiles/sage/cache/browser/state.db")) not in selected
+ assert str(Path("skills/example/cache/state.db")) in selected
+ assert "cache" in skipped
+ assert str(Path("profiles/sage/cache")) in skipped
+
def test_skipped_dirs_collected_for_summary(self, tmp_path):
from hermes_cli.backup import _iter_backup_files