Skip to content

Commit c22d7dc

Browse files
committed
omd backup: exclude generated core helper config
Backing up a running site could produce an unrestorable archive: the core rotates var/check_mk/core/helper_config/ generations during the backup, and a vanished hardlinked file left a dangling hardlink in the tar, making omd restore fail with a KeyError. Change-Id: I4cd24b78c4a8b859c1400c97d9c116b82c99b36f Jira: CMK-37169 Caused-by: Ic76bc983ebd221687e2f249bf6bcb3389f348aa2
1 parent 1119b1a commit c22d7dc

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

.werks/19719.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[//]: # (werk v2)
2+
# omd restore: Prevent 'KeyError: "linkname'
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-08-07T07:00:01.567466+00:00
7+
version | 2.4.0p36
8+
class | fix
9+
edition | cre
10+
component | omd
11+
level | 2
12+
compatible | yes
13+
14+
The backup of a running site could fail to restore.
15+
While the backup is created, the monitoring core could rotate the generated helper configuration below `var/check_mk/core/helper_config/`.
16+
This could corrupt the backup file and `omd restore` failed with an error like:
17+
18+
```
19+
KeyError: "linkname 'var/check_mk/core/helper_config/89/autochecks/....mk' not found"
20+
```
21+
22+
The helper configuration is now excluded from `omd backup` altogether.
23+
It is generated data and is recreated automatically (via `cmk -U`) when a backup is restored.

omd/packages/omd/omdlib/backup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def get_exclude_patterns(options: BackupExclusions) -> list[str]:
198198
excludes.append("var/check_mk/persisted/*")
199199
excludes.append("var/check_mk/persisted_sections/*")
200200

201+
# exclude the generated helper config, it is recreated by "cmk -U" during restore
202+
excludes.append("var/check_mk/core/helper_config/*")
203+
201204
if not options.rrds:
202205
excludes.append("var/pnp4nagios/perfdata/*")
203206
excludes.append("var/pnp4nagios/spool/*")

tests/unit/omdlib/test_omdlib_backup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_get_exclude_patterns_default() -> None:
104104
actual_excludes = get_exclude_patterns(BackupExclusions.from_options(options))
105105

106106
assert "tmp/*" in actual_excludes
107+
assert "var/check_mk/core/helper_config/*" in actual_excludes
107108
assert "var/check_mk/agents/*" not in actual_excludes
108109
assert "var/log/*/*" not in actual_excludes
109110
assert "var/check_mk/rrd/*" not in actual_excludes

0 commit comments

Comments
 (0)